Skip to content

Commit

Permalink
Merge branch 'master' into worker-fatal-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Mar 7, 2019
2 parents 3e98680 + b0cbcbf commit 70e173a
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

### Fixes

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

### Chore & Maintenance
Expand Down
7 changes: 6 additions & 1 deletion e2e/__tests__/runProgrammatically.test.ts
Expand Up @@ -11,7 +11,12 @@ import {run} from '../Utils';

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

test('run Jest programatically', () => {
test('run Jest programmatically cjs', () => {
const {stdout} = run(`node cjs.js --version`, dir);
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
});

test('run Jest programmatically esm', () => {
const {stdout} = run(`node index.js --version`, dir);
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
});
5 changes: 5 additions & 0 deletions e2e/run-programmatically/babel.config.js
@@ -0,0 +1,5 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

module.exports = {
presets: ['@babel/preset-env'],
};
12 changes: 12 additions & 0 deletions e2e/run-programmatically/cjs.js
@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// Running Jest like this is not officially supported,
// but it is common practice until there is a proper API as a substitute.
require('jest').run(process.argv);
14 changes: 14 additions & 0 deletions e2e/run-programmatically/esm.js
@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import myJestImport from 'jest';

// Running Jest like this is not officially supported,
// but it is common practice until there is a proper API as a substitute.
myJestImport.run(process.argv);
6 changes: 3 additions & 3 deletions e2e/run-programmatically/index.js
Expand Up @@ -8,6 +8,6 @@
* @flow
*/

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

require('./esm');
17 changes: 13 additions & 4 deletions packages/jest-cli/src/index.ts
Expand Up @@ -5,7 +5,16 @@
* LICENSE file in the root directory of this source tree.
*/

// TODO: remove exports for the next major
export {runCLI, SearchSource, TestScheduler, TestWatcher} from '@jest/core';
export {run} from './cli';
export {default as getVersion} from './version';
// TODO: remove @jest/core exports for the next major
import {runCLI, SearchSource, TestScheduler, TestWatcher} from '@jest/core';
import {run} from './cli';
import {default as getVersion} from './version';

export = {
SearchSource,
TestScheduler,
TestWatcher,
getVersion,
run,
runCLI,
};
2 changes: 1 addition & 1 deletion packages/jest-core/package.json
Expand Up @@ -34,7 +34,7 @@
"strip-ansi": "^5.0.0"
},
"devDependencies": {
"@types/ansi-escapes": "^3.0.0",
"@types/ansi-escapes": "^3.0.1",
"@types/exit": "^0.1.30",
"@types/graceful-fs": "^4.1.2",
"@types/micromatch": "^3.1.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-core/src/watch.ts
Expand Up @@ -239,7 +239,6 @@ export default function watch(
hasExitListener = true;
process.on('exit', () => {
if (activePlugin) {
// @ts-ignore: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33423
outputStream.write(ansiEscapes.cursorDown());
outputStream.write(ansiEscapes.eraseDown);
}
Expand Down Expand Up @@ -404,7 +403,6 @@ export default function watch(
break;
case 'w':
if (!shouldDisplayWatchUsage && !isWatchUsageDisplayed) {
// @ts-ignore: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33423
outputStream.write(ansiEscapes.cursorUp());
outputStream.write(ansiEscapes.eraseDown);
outputStream.write(usage(globalConfig, watchPlugins));
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1564,10 +1564,10 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==

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

Expand Down

0 comments on commit 70e173a

Please sign in to comment.