Skip to content

Commit

Permalink
chore: merge facebook master
Browse files Browse the repository at this point in the history
  • Loading branch information
sauravhiremath committed Dec 25, 2020
2 parents 5d68ded + 4102243 commit d905d2c
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -25,6 +25,7 @@
- `[expect]` [**BREAKING**] Make `toContain` more strict with the received type ([#10119](https://github.com/facebook/jest/pull/10119) & [#10929](https://github.com/facebook/jest/pull/10929))
- `[jest-circus]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block [#10451](https://github.com/facebook/jest/issues/10451)
- `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871))
- `[jest-cli]` Use testFailureExitCode when bailing from a failed test ([#10958](https://github.com/facebook/jest/pull/10958))
- `[jest-config]` [**BREAKING**] Change default file extension order by moving json behind ts and tsx ([10572](https://github.com/facebook/jest/pull/10572))
- `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638))
- `[jest-each]` [**BREAKING**] Ignore excess words in headings ([#8766](https://github.com/facebook/jest/pull/8766))
Expand Down Expand Up @@ -63,6 +64,7 @@
- `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688))
- `[jest-resolve-dependencies]` [**BREAKING**] Migrate to ESM ([#10876](https://github.com/facebook/jest/pull/10876))
- `[jest-mock]` [**BREAKING**] Migrate to ESM ([#10887](https://github.com/facebook/jest/pull/10887))
- `[jest-reporters]` [**BREAKING**] Make `node-notifier` a peer dependency ([#10977](https://github.com/facebook/jest/pull/10977))
- `[jest-resolve, jest-runtime]` [**BREAKING**] Use `Map`s instead of objects for all cached resources ([#10968](https://github.com/facebook/jest/pull/10968))
- `[jest-runner]` [**BREAKING**] Migrate to ESM ([#10900](https://github.com/facebook/jest/pull/10900))
- `[jest-runtime]` [**BREAKING**] Remove deprecated and unnused `getSourceMapInfo` from Runtime ([#9969](https://github.com/facebook/jest/pull/9969))
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/jestChangedFiles.test.ts
Expand Up @@ -21,9 +21,9 @@ const HG = 'hg --config ui.username=jest_test';

const gitVersionSupportsInitialBranch = (() => {
const {stdout} = run(`${GIT} --version`);
const gitVersion = stdout.split(' ').slice(-1)[0];
const gitVersion = stdout.trim();

const match = gitVersion.match(/(?<version>\d+\.\d+\.\d+)/);
const match = gitVersion.match(/^git version (?<version>\d+\.\d+\.\d+)/);

if (match?.groups?.version == null) {
throw new Error(`Unable to parse git version from string "${gitVersion}"`);
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/onlyChanged.test.ts
Expand Up @@ -17,9 +17,9 @@ const HG = 'hg --config ui.username=jest_test';

const gitVersionSupportsInitialBranch = (() => {
const {stdout} = run(`${GIT} --version`);
const gitVersion = stdout.split(' ').slice(-1)[0];
const gitVersion = stdout.trim();

const match = gitVersion.match(/(?<version>\d+\.\d+\.\d+)/);
const match = gitVersion.match(/^git version (?<version>\d+\.\d+\.\d+)/);

if (match?.groups?.version == null) {
throw new Error(`Unable to parse git version from string "${gitVersion}"`);
Expand Down
26 changes: 26 additions & 0 deletions e2e/__tests__/testFailureExitCode.test.ts
Expand Up @@ -38,3 +38,29 @@ test('exits with a specified code when test fail', () => {
({exitCode} = runJest(DIR));
expect(exitCode).toBe(1);
});

test('exits with a specified code when bailing from a failed test', () => {
writeFiles(DIR, {
'__tests__/test.test.js': `test('test', () => { expect(1).toBe(2); });`,
'__tests__/test2.test.js': `test('test2', () => { expect(1).toBe(2); });`,
'package.json': JSON.stringify({
jest: {testEnvironment: 'node', testFailureExitCode: 99},
}),
});

let {exitCode} = runJest(DIR, ['--bail']);
expect(exitCode).toBe(99);

({exitCode} = runJest(DIR, ['--bail', '--testFailureExitCode', '77']));
expect(exitCode).toBe(77);

writeFiles(DIR, {
'__tests__/test.test.js': `test('test', () => { expect(1).toBe(2); });`,
'__tests__/test2.test.js': `test('test2', () => { expect(1).toBe(2); });`,
'package.json': JSON.stringify({
jest: {testEnvironment: 'node'},
}),
});
({exitCode} = runJest(DIR));
expect(exitCode).toBe(1);
});
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -65,6 +65,7 @@
"micromatch": "^4.0.2",
"mlh-tsd": "^0.14.1",
"mock-fs": "^4.4.1",
"node-notifier": "^9.0.0",
"prettier": "^2.1.1",
"progress": "^2.0.0",
"promise": "^8.0.2",
Expand Down
8 changes: 8 additions & 0 deletions packages/jest-cli/package.json
Expand Up @@ -32,6 +32,14 @@
"@types/prompts": "^2.0.1",
"@types/yargs": "^15.0.0"
},
"peerDependencies": {
"node-notifier": "^8.0.1 || ^9.0.0"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
},
"bin": {
"jest": "./bin/jest.js"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/jest-core/package.json
Expand Up @@ -48,6 +48,14 @@
"@types/rimraf": "^3.0.0",
"jest-snapshot-serializer-raw": "^1.1.0"
},
"peerDependencies": {
"node-notifier": "^8.0.1 || ^9.0.0"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-core/src/TestScheduler.ts
Expand Up @@ -416,7 +416,8 @@ export default class TestScheduler {
try {
await this._dispatcher.onRunComplete(contexts, aggregatedResults);
} finally {
exit(1);
const exitCode = this._globalConfig.testFailureExitCode;
exit(exitCode);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions packages/jest-reporters/package.json
Expand Up @@ -48,8 +48,13 @@
"mock-fs": "^4.4.1",
"strip-ansi": "^6.0.0"
},
"optionalDependencies": {
"node-notifier": "^8.0.0"
"peerDependencies": {
"node-notifier": "^8.0.1 || ^9.0.0"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-reporters/src/NotifyReporter.ts
Expand Up @@ -145,10 +145,10 @@ function loadNotifier(): typeof import('node-notifier') {
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err;
} else {
throw Error(
'notify reporter requires optional dependeny node-notifier but it was not found',
);
}

throw Error(
'notify reporter requires optional peer dependency "node-notifier" but it was not found',
);
}
}
5 changes: 2 additions & 3 deletions packages/jest-reporters/src/__tests__/NotifyReporter.test.ts
Expand Up @@ -224,14 +224,13 @@ describe('node-notifier is an optional dependency', () => {

test('without node-notifier uses mock function that throws an error', () => {
jest.doMock('node-notifier', () => {
const error: unknown = new Resolver.ModuleNotFoundError(
throw new Resolver.ModuleNotFoundError(
"Cannot find module 'node-notifier'",
);
throw error;
});

expect(ctor).toThrow(
'notify reporter requires optional dependeny node-notifier but it was not found',
'notify reporter requires optional peer dependency "node-notifier" but it was not found',
);
});

Expand Down
8 changes: 8 additions & 0 deletions packages/jest/package.json
Expand Up @@ -14,6 +14,14 @@
"import-local": "^3.0.2",
"jest-cli": "^27.0.0-next.2"
},
"peerDependencies": {
"node-notifier": "^8.0.1 || ^9.0.0"
},
"peerDependenciesMeta": {
"node-notifier": {
"optional": true
}
},
"bin": "./bin/jest.js",
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/src/__tests__/ReactElement.test.ts
Expand Up @@ -15,7 +15,7 @@ setPrettyPrint([ReactElement]);

describe('ReactElement Plugin', () => {
let forwardRefComponent: {
(_props: unknown, _ref: unknown): unknown;
(_props: unknown, _ref: unknown): React.ReactElement | null;
displayName?: string;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/src/__tests__/react.test.tsx
Expand Up @@ -706,7 +706,7 @@ test('ReactTestComponent plugin highlights syntax with color from theme option',
});

test('supports forwardRef with a child', () => {
function Cat(props: any) {
function Cat(props: any, _ref: any) {
return React.createElement('div', props, props.children);
}

Expand Down
29 changes: 23 additions & 6 deletions yarn.lock
Expand Up @@ -1820,6 +1820,11 @@ __metadata:
rimraf: ^3.0.0
slash: ^3.0.0
strip-ansi: ^6.0.0
peerDependencies:
node-notifier: ^8.0.1 || ^9.0.0
peerDependenciesMeta:
node-notifier:
optional: true
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1945,6 +1950,7 @@ __metadata:
micromatch: ^4.0.2
mlh-tsd: ^0.14.1
mock-fs: ^4.4.1
node-notifier: ^9.0.0
prettier: ^2.1.1
progress: ^2.0.0
promise: ^8.0.2
Expand Down Expand Up @@ -2000,14 +2006,15 @@ __metadata:
jest-util: ^27.0.0-next.1
jest-worker: ^27.0.0-next.2
mock-fs: ^4.4.1
node-notifier: ^8.0.0
slash: ^3.0.0
source-map: ^0.6.0
string-length: ^4.0.1
strip-ansi: ^6.0.0
terminal-link: ^2.0.0
v8-to-istanbul: ^7.0.0
dependenciesMeta:
peerDependencies:
node-notifier: ^8.0.1 || ^9.0.0
peerDependenciesMeta:
node-notifier:
optional: true
languageName: unknown
Expand Down Expand Up @@ -11591,6 +11598,11 @@ fsevents@^1.2.7:
jest-validate: ^27.0.0-next.1
prompts: ^2.0.1
yargs: ^16.0.3
peerDependencies:
node-notifier: ^8.0.1 || ^9.0.0
peerDependenciesMeta:
node-notifier:
optional: true
bin:
jest: ./bin/jest.js
languageName: unknown
Expand Down Expand Up @@ -12362,6 +12374,11 @@ fsevents@^1.2.7:
"@jest/core": ^27.0.0-next.2
import-local: ^3.0.2
jest-cli: ^27.0.0-next.2
peerDependencies:
node-notifier: ^8.0.1 || ^9.0.0
peerDependenciesMeta:
node-notifier:
optional: true
bin:
jest: ./bin/jest.js
languageName: unknown
Expand Down Expand Up @@ -14559,17 +14576,17 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"node-notifier@npm:^8.0.0":
version: 8.0.0
resolution: "node-notifier@npm:8.0.0"
"node-notifier@npm:^9.0.0":
version: 9.0.0
resolution: "node-notifier@npm:9.0.0"
dependencies:
growly: ^1.3.0
is-wsl: ^2.2.0
semver: ^7.3.2
shellwords: ^0.1.1
uuid: ^8.3.0
which: ^2.0.2
checksum: 3016eccb32cbfc0ec26129500570a0d875c32e28c43aef9c32d4cea24617cdd870eaf39247faffed5b89f78ef69ca4506270d2f8f76f027222597b700cc8aec9
checksum: 10e6ba45afb246ea8bd0189960b883c4c0cb04de82a7c091b536f7652327910a4929fd3862cc32bdea20e53bb52a4ddae2ff1eb3aee751aba6e27242602193b3
languageName: node
linkType: hard

Expand Down

0 comments on commit d905d2c

Please sign in to comment.