Skip to content

Commit f3e3ffe

Browse files
committed
Merge remote-tracking branch 'facebook/master' into 14839
* facebook/master: fix 1-indexed JEST_WORKER_ID (jestjs#8205) remove flow leftovers (jestjs#8213)
2 parents ab893e4 + 54ce3f3 commit f3e3ffe

File tree

18 files changed

+11
-27
lines changed

18 files changed

+11
-27
lines changed

.circleci/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
- restore-cache: *restore-cache
2727
- run: yarn --no-progress --frozen-lockfile
2828
- save-cache: *save-cache
29-
- run: echo server.max_workers=1 >> .flowconfig
3029
- 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
3130
- store_test_results:
3231
path: reports/junit

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- `[pretty-format]` Print `BigInt` as a readable number instead of `{}` ([#8138](https://github.com/facebook/jest/pull/8138))
2121
- `[jest-core]` Fix ability to transform dependencies required from globalSetup script [#8143](https://github.com/facebook/jest/pull/8143)
2222
- `[@jest/reporters]` Fix Cannot read property converageData of null ([#8168](https://github.com/facebook/jest/pull/8168))
23+
- `[jest-worker]` `JEST_WORKER_ID` starts at 1 ([#8205](https://github.com/facebook/jest/pull/8205))
2324
- `[jest-resolve-dependencies]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))
2425
- `[jest-resolve]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))
2526
- `[jest-snapshot]`: Move internal peer dependencies to dependencies ([#8215](https://github.com/facebook/jest/pull/8215))

e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ FAIL __tests__/index.js
3030
12 | module.exports = () => 'test';
3131
13 |
3232
33-
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:474:17)
33+
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:473:17)
3434
at Object.require (index.js:10:1)
3535
`;

e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ FAIL __tests__/test.js
3333
| ^
3434
4 |
3535
36-
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:232:17)
36+
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:231:17)
3737
at Object.require (index.js:3:18)
3838
`;

packages/expect/src/jasmineUtils.ts

-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ function asymmetricMatch(a: any, b: any) {
5050
}
5151

5252
if (asymmetricA) {
53-
// $FlowFixMe – Flow sees `a` as a number
5453
return a.asymmetricMatch(b);
5554
}
5655

@@ -103,7 +102,6 @@ function eq(
103102
case '[object String]':
104103
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
105104
// equivalent to `new String("5")`.
106-
// $FlowFixMe – Flow sees `a` as a number
107105
return a == String(b);
108106
case '[object Number]':
109107
return Object.is(Number(a), Number(b));
@@ -119,7 +117,6 @@ function eq(
119117
a.source == b.source &&
120118
a.global == b.global &&
121119
a.multiline == b.multiline &&
122-
// $FlowFixMe – Flow sees `a` as a number
123120
a.ignoreCase == b.ignoreCase
124121
);
125122
}
@@ -210,7 +207,6 @@ function keys(
210207
}
211208
return keys.concat(
212209
(Object.getOwnPropertySymbols(o) as Array<any>).filter(
213-
//$FlowFixMe Jest complains about nullability, but we know for sure that property 'symbol' does exist.
214210
symbol =>
215211
(Object.getOwnPropertyDescriptor(o, symbol) as any).enumerable,
216212
),

packages/jest-cli/src/init/__tests__/init.test.js

-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ const consoleLog = console.log;
2525

2626
describe('init', () => {
2727
beforeEach(() => {
28-
// $FlowFixMe mock console.log to reduce noise from the tests
2928
console.log = jest.fn();
30-
// $FlowFixMe mock
3129
fs.writeFileSync = jest.fn();
3230
});
3331

3432
afterEach(() => {
3533
jest.clearAllMocks();
36-
// $FlowFixMe
3734
console.log = consoleLog;
38-
// $FlowFixMe mock
3935
fs.writeFileSync = writeFileSync;
4036
});
4137

packages/jest-config/src/setFromArgv.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default function setFromArgv(
1414
options: Config.InitialOptions,
1515
argv: Config.Argv,
1616
): Config.InitialOptions {
17-
// $FlowFixMe: Seems like flow doesn't approve of string values
1817
const argvToOptions = Object.keys(argv)
1918
.filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1)
2019
.reduce((options: {[key: string]: unknown}, key) => {

packages/jest-jasmine2/src/assertionErrorMessage.ts

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const getOperatorName = (operator: string | null, stack: string) => {
4747

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

5352
return typeof operator === 'string'

packages/jest-jasmine2/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ async function jasmine2(
127127
if (globalConfig.errorOnDeprecated) {
128128
installErrorOnPrivate(environment.global);
129129
} else {
130-
// $FlowFixMe Flow seems to be confused about accessors and tries to enforce having a `value` property.
131130
Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
132131
configurable: true,
133132
enumerable: true,

packages/jest-jasmine2/src/setup_jest_globals.ts

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export default ({
105105
expand,
106106
getBabelTraverse: () => require('@babel/traverse').default,
107107
getPrettier: () =>
108-
// $FlowFixMe dynamic require
109108
config.prettierPath ? require(config.prettierPath) : null,
110109
updateSnapshot,
111110
});

packages/jest-resolve/src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ class Resolver {
8383
options: FindNodeModuleConfig,
8484
): Config.Path | null {
8585
const resolver = options.resolver
86-
? /* $FlowFixMe */
87-
require(options.resolver)
86+
? require(options.resolver)
8887
: defaultResolver;
8988
const paths = options.paths;
9089

packages/jest-util/src/deepCyclicCopy.ts

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function deepCyclicCopyObject<T>(
5454
? Object.create(Object.getPrototypeOf(object))
5555
: {};
5656

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

6059
cycles.set(object, newObject);

packages/jest-worker/src/WorkerPool.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818

1919
const canUseWorkerThreads = () => {
2020
try {
21-
// $FlowFixMe: Flow doesn't know about experimental APIs
2221
require('worker_threads');
2322
return true;
2423
} catch (_) {

packages/jest-worker/src/workers/ChildProcessWorker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default class ChildProcessWorker implements WorkerInterface {
6767
cwd: process.cwd(),
6868
env: {
6969
...process.env,
70-
JEST_WORKER_ID: String(this._options.workerId),
70+
JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID
7171
...forceColor,
7272
} as NodeJS.ProcessEnv,
7373
// Suppress --debug / --inspect flags while preserving others (like --harmony).

packages/jest-worker/src/workers/NodeThreadsWorker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class ExperimentalWorker implements WorkerInterface {
5454
cwd: process.cwd(),
5555
env: {
5656
...process.env,
57-
JEST_WORKER_ID: String(this._options.workerId),
57+
JEST_WORKER_ID: String(this._options.workerId + 1), // 0-indexed workerId, 1-indexed JEST_WORKER_ID
5858
} as NodeJS.ProcessEnv,
5959
// Suppress --debug / --inspect flags while preserving others (like --harmony).
6060
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),

packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
5858
execPath: 'hello',
5959
},
6060
maxRetries: 3,
61-
workerId: process.env.JEST_WORKER_ID,
61+
workerId: process.env.JEST_WORKER_ID - 1,
6262
workerPath: '/tmp/foo/bar/baz.js',
6363
});
6464

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

75-
it('passes workerId to the child process and assign it to env.JEST_WORKER_ID', () => {
75+
it('passes workerId to the child process and assign it to 1-indexed env.JEST_WORKER_ID', () => {
7676
new Worker({
7777
forkOptions: {},
7878
maxRetries: 3,
7979
workerId: 2,
8080
workerPath: '/tmp/foo',
8181
});
8282

83-
expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toEqual('2');
83+
expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toEqual('3');
8484
});
8585

8686
it('initializes the child process with the given workerPath', () => {

packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
6363
execPath: 'hello',
6464
},
6565
maxRetries: 3,
66-
workerId: process.env.JEST_WORKER_ID,
66+
workerId: process.env.JEST_WORKER_ID - 1,
6767
workerPath: '/tmp/foo/bar/baz.js',
6868
});
6969

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

9393
expect(childProcess.mock.calls[0][1].workerData.env.JEST_WORKER_ID).toEqual(
94-
'2',
94+
'3',
9595
);
9696
});
9797

packages/jest-worker/src/workers/processChild.ts

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ function reportError(error: Error, type: PARENT_MESSAGE_ERROR) {
8888
error.constructor && error.constructor.name,
8989
error.message,
9090
error.stack,
91-
// $FlowFixMe: this is safe to just inherit from Object.
9291
typeof error === 'object' ? {...error} : error,
9392
]);
9493
}

0 commit comments

Comments
 (0)