Skip to content

Commit 70e173a

Browse files
authored
Merge branch 'master' into worker-fatal-errors
2 parents 3e98680 + b0cbcbf commit 70e173a

10 files changed

Lines changed: 59 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixes
66

7+
- `[jest-cli]` export functions compatible with `import {default}` ([#8080](https://github.com/facebook/jest/pull/8080))
78
- `[jest-worker]`: Fix retries and error notification in workers ([#8079](https://github.com/facebook/jest/pull/8079))
89

910
### Chore & Maintenance

e2e/__tests__/runProgrammatically.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {run} from '../Utils';
1111

1212
const dir = resolve(__dirname, '..', 'run-programmatically');
1313

14-
test('run Jest programatically', () => {
14+
test('run Jest programmatically cjs', () => {
15+
const {stdout} = run(`node cjs.js --version`, dir);
16+
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
17+
});
18+
19+
test('run Jest programmatically esm', () => {
1520
const {stdout} = run(`node index.js --version`, dir);
1621
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
1722
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2+
3+
module.exports = {
4+
presets: ['@babel/preset-env'],
5+
};

e2e/run-programmatically/cjs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
// Running Jest like this is not officially supported,
11+
// but it is common practice until there is a proper API as a substitute.
12+
require('jest').run(process.argv);

e2e/run-programmatically/esm.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
import myJestImport from 'jest';
11+
12+
// Running Jest like this is not officially supported,
13+
// but it is common practice until there is a proper API as a substitute.
14+
myJestImport.run(process.argv);

e2e/run-programmatically/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
* @flow
99
*/
1010

11-
// Running Jest like this is not officially supported,
12-
// but it is common practice until there is a proper API as a substitute.
13-
require('jest').run(process.argv);
11+
require('@babel/register');
12+
13+
require('./esm');

packages/jest-cli/src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
// TODO: remove exports for the next major
9-
export {runCLI, SearchSource, TestScheduler, TestWatcher} from '@jest/core';
10-
export {run} from './cli';
11-
export {default as getVersion} from './version';
8+
// TODO: remove @jest/core exports for the next major
9+
import {runCLI, SearchSource, TestScheduler, TestWatcher} from '@jest/core';
10+
import {run} from './cli';
11+
import {default as getVersion} from './version';
12+
13+
export = {
14+
SearchSource,
15+
TestScheduler,
16+
TestWatcher,
17+
getVersion,
18+
run,
19+
runCLI,
20+
};

packages/jest-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"strip-ansi": "^5.0.0"
3535
},
3636
"devDependencies": {
37-
"@types/ansi-escapes": "^3.0.0",
37+
"@types/ansi-escapes": "^3.0.1",
3838
"@types/exit": "^0.1.30",
3939
"@types/graceful-fs": "^4.1.2",
4040
"@types/micromatch": "^3.1.0",

packages/jest-core/src/watch.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ export default function watch(
239239
hasExitListener = true;
240240
process.on('exit', () => {
241241
if (activePlugin) {
242-
// @ts-ignore: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33423
243242
outputStream.write(ansiEscapes.cursorDown());
244243
outputStream.write(ansiEscapes.eraseDown);
245244
}
@@ -404,7 +403,6 @@ export default function watch(
404403
break;
405404
case 'w':
406405
if (!shouldDisplayWatchUsage && !isWatchUsageDisplayed) {
407-
// @ts-ignore: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33423
408406
outputStream.write(ansiEscapes.cursorUp());
409407
outputStream.write(ansiEscapes.eraseDown);
410408
outputStream.write(usage(globalConfig, watchPlugins));

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,10 +1564,10 @@
15641564
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
15651565
integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==
15661566

1567-
"@types/ansi-escapes@^3.0.0":
1568-
version "3.0.0"
1569-
resolved "https://registry.yarnpkg.com/@types/ansi-escapes/-/ansi-escapes-3.0.0.tgz#619bbc6d46fc75da6d784e53b5a25d2efff07108"
1570-
integrity sha512-aamJrX6PdmIO8E9qhZaYmXiMGXwnkF2lcga/VbqLf8g90aaKGZ4cSFP5AabqxAbmp0h69C9yE3a4fUBtVpqtmg==
1567+
"@types/ansi-escapes@^3.0.0", "@types/ansi-escapes@^3.0.1":
1568+
version "3.0.1"
1569+
resolved "https://registry.yarnpkg.com/@types/ansi-escapes/-/ansi-escapes-3.0.1.tgz#328e46c6ac3177ca4cf2efdeed326cf77da01ef7"
1570+
integrity sha512-GD/QLUGxSvy3yGQb+m12qsRtP4p/dewNePDb5F8qV19CXuO+gtbsmMjjsClpG/Nu84y8SF1zPKrTnQZHDiPUgg==
15711571
dependencies:
15721572
"@types/node" "*"
15731573

0 commit comments

Comments
 (0)