Skip to content

Commit

Permalink
Merge remote-tracking branch 'facebook/master' into 14839
Browse files Browse the repository at this point in the history
* facebook/master:
  fix 1-indexed JEST_WORKER_ID (jestjs#8205)
  remove flow leftovers (jestjs#8213)
  • Loading branch information
Hoishin committed Mar 26, 2019
2 parents ab893e4 + 54ce3f3 commit f3e3ffe
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 27 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- restore-cache: *restore-cache
- run: yarn --no-progress --frozen-lockfile
- save-cache: *save-cache
- run: echo server.max_workers=1 >> .flowconfig
- run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci && yarn check-copyright-headers
- store_test_results:
path: reports/junit
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `[pretty-format]` Print `BigInt` as a readable number instead of `{}` ([#8138](https://github.com/facebook/jest/pull/8138))
- `[jest-core]` Fix ability to transform dependencies required from globalSetup script [#8143](https://github.com/facebook/jest/pull/8143)
- `[@jest/reporters]` Fix Cannot read property converageData of null ([#8168](https://github.com/facebook/jest/pull/8168))
- `[jest-worker]` `JEST_WORKER_ID` starts at 1 ([#8205](https://github.com/facebook/jest/pull/8205))
- `[jest-resolve-dependencies]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))
- `[jest-resolve]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))
- `[jest-snapshot]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ FAIL __tests__/index.js
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:474:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:473:17)
at Object.require (index.js:10:1)
`;
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ FAIL __tests__/test.js
| ^
4 |
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:232:17)
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:231:17)
at Object.require (index.js:3:18)
`;
4 changes: 0 additions & 4 deletions packages/expect/src/jasmineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function asymmetricMatch(a: any, b: any) {
}

if (asymmetricA) {
// $FlowFixMe – Flow sees `a` as a number
return a.asymmetricMatch(b);
}

Expand Down Expand Up @@ -103,7 +102,6 @@ function eq(
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
// $FlowFixMe – Flow sees `a` as a number
return a == String(b);
case '[object Number]':
return Object.is(Number(a), Number(b));
Expand All @@ -119,7 +117,6 @@ function eq(
a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
// $FlowFixMe – Flow sees `a` as a number
a.ignoreCase == b.ignoreCase
);
}
Expand Down Expand Up @@ -210,7 +207,6 @@ function keys(
}
return keys.concat(
(Object.getOwnPropertySymbols(o) as Array<any>).filter(
//$FlowFixMe Jest complains about nullability, but we know for sure that property 'symbol' does exist.
symbol =>
(Object.getOwnPropertyDescriptor(o, symbol) as any).enumerable,
),
Expand Down
4 changes: 0 additions & 4 deletions packages/jest-cli/src/init/__tests__/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ const consoleLog = console.log;

describe('init', () => {
beforeEach(() => {
// $FlowFixMe mock console.log to reduce noise from the tests
console.log = jest.fn();
// $FlowFixMe mock
fs.writeFileSync = jest.fn();
});

afterEach(() => {
jest.clearAllMocks();
// $FlowFixMe
console.log = consoleLog;
// $FlowFixMe mock
fs.writeFileSync = writeFileSync;
});

Expand Down
1 change: 0 additions & 1 deletion packages/jest-config/src/setFromArgv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function setFromArgv(
options: Config.InitialOptions,
argv: Config.Argv,
): Config.InitialOptions {
// $FlowFixMe: Seems like flow doesn't approve of string values
const argvToOptions = Object.keys(argv)
.filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1)
.reduce((options: {[key: string]: unknown}, key) => {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-jasmine2/src/assertionErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const getOperatorName = (operator: string | null, stack: string) => {

const operatorMessage = (operator: string | null) => {
const niceOperatorName = getOperatorName(operator, '');
// $FlowFixMe: we default to the operator itself, so holes in the map doesn't matter
const humanReadableOperator = humanReadableOperators[niceOperatorName];

return typeof operator === 'string'
Expand Down
1 change: 0 additions & 1 deletion packages/jest-jasmine2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ async function jasmine2(
if (globalConfig.errorOnDeprecated) {
installErrorOnPrivate(environment.global);
} else {
// $FlowFixMe Flow seems to be confused about accessors and tries to enforce having a `value` property.
Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
configurable: true,
enumerable: true,
Expand Down
1 change: 0 additions & 1 deletion packages/jest-jasmine2/src/setup_jest_globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export default ({
expand,
getBabelTraverse: () => require('@babel/traverse').default,
getPrettier: () =>
// $FlowFixMe dynamic require
config.prettierPath ? require(config.prettierPath) : null,
updateSnapshot,
});
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class Resolver {
options: FindNodeModuleConfig,
): Config.Path | null {
const resolver = options.resolver
? /* $FlowFixMe */
require(options.resolver)
? require(options.resolver)
: defaultResolver;
const paths = options.paths;

Expand Down
1 change: 0 additions & 1 deletion packages/jest-util/src/deepCyclicCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function deepCyclicCopyObject<T>(
? Object.create(Object.getPrototypeOf(object))
: {};

// $FlowFixMe: Object.getOwnPropertyDescriptors is polyfilled above.
const descriptors = Object.getOwnPropertyDescriptors(object);

cycles.set(object, newObject);
Expand Down
1 change: 0 additions & 1 deletion packages/jest-worker/src/WorkerPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {

const canUseWorkerThreads = () => {
try {
// $FlowFixMe: Flow doesn't know about experimental APIs
require('worker_threads');
return true;
} catch (_) {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/workers/ChildProcessWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class ChildProcessWorker implements WorkerInterface {
cwd: process.cwd(),
env: {
...process.env,
JEST_WORKER_ID: String(this._options.workerId),
JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID
...forceColor,
} as NodeJS.ProcessEnv,
// Suppress --debug / --inspect flags while preserving others (like --harmony).
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/workers/NodeThreadsWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ExperimentalWorker implements WorkerInterface {
cwd: process.cwd(),
env: {
...process.env,
JEST_WORKER_ID: String(this._options.workerId),
JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID
} as NodeJS.ProcessEnv,
// Suppress --debug / --inspect flags while preserving others (like --harmony).
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
execPath: 'hello',
},
maxRetries: 3,
workerId: process.env.JEST_WORKER_ID,
workerId: process.env.JEST_WORKER_ID - 1,
workerPath: '/tmp/foo/bar/baz.js',
});

Expand All @@ -72,15 +72,15 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
});
});

it('passes workerId to the child process and assign it to env.JEST_WORKER_ID', () => {
it('passes workerId to the child process and assign it to 1-indexed env.JEST_WORKER_ID', () => {
new Worker({
forkOptions: {},
maxRetries: 3,
workerId: 2,
workerPath: '/tmp/foo',
});

expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toEqual('2');
expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toEqual('3');
});

it('initializes the child process with the given workerPath', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
execPath: 'hello',
},
maxRetries: 3,
workerId: process.env.JEST_WORKER_ID,
workerId: process.env.JEST_WORKER_ID - 1,
workerPath: '/tmp/foo/bar/baz.js',
});

Expand Down Expand Up @@ -91,7 +91,7 @@ it('passes workerId to the child process and assign it to env.JEST_WORKER_ID', (
});

expect(childProcess.mock.calls[0][1].workerData.env.JEST_WORKER_ID).toEqual(
'2',
'3',
);
});

Expand Down
1 change: 0 additions & 1 deletion packages/jest-worker/src/workers/processChild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function reportError(error: Error, type: PARENT_MESSAGE_ERROR) {
error.constructor && error.constructor.name,
error.message,
error.stack,
// $FlowFixMe: this is safe to just inherit from Object.
typeof error === 'object' ? {...error} : error,
]);
}
Expand Down

0 comments on commit f3e3ffe

Please sign in to comment.