Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
- `[*]` [**BREAKING**] Require Node.js 6+ for all packages ([#7258](https://github.com/facebook/jest/pull/7258))
- `[*]` [**BREAKING**] Use ESM `import` and `export` all over ([#7548](https://github.com/facebook/jest/pull/7548))
- `[jest-util]` [**BREAKING**] Remove long-deprecated globals for fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[*]` [**BREAKING**] Remove regenerator-runtime injection ([#7595](https://github.com/facebook/jest/pull/7595))
- `[docs]` Fix message property in custom matcher example to return a function instead of a constant. ([#7426](https://github.com/facebook/jest/pull/7426))
- `[jest-circus]` Standardize file naming in `jest-circus` ([#7301](https://github.com/facebook/jest/pull/7301))
- `[docs]` Add synchronous test.each setup ([#7150](https://github.com/facebook/jest/pull/7150))
Expand Down
4 changes: 0 additions & 4 deletions e2e/custom-resolver/__tests__/customResolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ test('should use the custom resolver', () => {
require('foo');
});

test('should have regenerator injected', () => {
expect(global.fakeRegeneratorInjected).toEqual(true);
});

test('should work with automock', () => {
jest.mock('foo');

Expand Down
3 changes: 0 additions & 3 deletions e2e/custom-resolver/fakeRegenerator.js

This file was deleted.

6 changes: 1 addition & 5 deletions e2e/custom-resolver/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ const {
default: defaultResolver,
} = require('jest-resolve/build/defaultResolver');

const exportedModules = new Map([
['foo', 'foo'],
['bar', 'bar'],
['regenerator-runtime/runtime', 'fakeRegenerator'],
]);
const exportedModules = new Map([['foo', 'foo'], ['bar', 'bar']]);

module.exports = (name, options) => {
const resolution = exportedModules.get(name);
Expand Down
3 changes: 1 addition & 2 deletions e2e/native-async-mock/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

module.exports = {
plugins: ['@babel/plugin-transform-async-to-generator'],
presets: ['@babel/preset-env'],
presets: [['@babel/preset-env', {targets: {node: 8}}]],
Comment thread
SimenB marked this conversation as resolved.
Outdated
};
1 change: 0 additions & 1 deletion e2e/native-async-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
},
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.0.0",
"@babel/preset-env": "^7.0.0"
}
}
2 changes: 1 addition & 1 deletion e2e/native-async-mock/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-async-to-generator@^7.0.0", "@babel/plugin-transform-async-to-generator@^7.1.0":
"@babel/plugin-transform-async-to-generator@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.1.0.tgz#109e036496c51dd65857e16acab3bafdf3c57811"
integrity sha512-rNmcmoQ78IrvNCIt/R9U+cixUHeYAzgusTFgIAv+wQb9HJU4szhpDD6e5GCACmj/JP5KxuCwM96bX3L9v4ZN/g==
Expand Down
11 changes: 2 additions & 9 deletions examples/async/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
module.exports = {
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
],
presets: ['@babel/preset-env'],
// See https://babeljs.io/docs/en/babel-preset-env#targets
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
Comment thread
SimenB marked this conversation as resolved.
};
3 changes: 1 addition & 2 deletions examples/async/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "0.0.0",
"name": "example-async",
"devDependencies": {
"@babel/plugin-transform-runtime": "*",
"@babel/core": "*",
"@babel/preset-env": "*",
"@babel/runtime": "*",
"babel-jest": "*",
Comment thread
SimenB marked this conversation as resolved.
"jest": "*"
},
Expand Down
2 changes: 2 additions & 0 deletions examples/automatic-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-automatic-mocks",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions examples/enzyme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"react-dom": "^16.4.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
2 changes: 2 additions & 0 deletions examples/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-getting-started",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions examples/jquery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-jquery",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions examples/manual-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-manual-mocks",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions examples/module-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-manual-mock",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions examples/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"react-native": "0.57.3"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*",
Expand Down
1 change: 1 addition & 0 deletions examples/react-testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"react-dom": "^16.4.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
1 change: 1 addition & 0 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"react-dom": "^16.4.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
4 changes: 2 additions & 2 deletions examples/snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"react": "^16.4.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
"jest": "*",
"react-test-renderer": "*",
"regenerator-runtime": "*"
"react-test-renderer": "*"
},
"scripts": {
"test": "jest"
Expand Down
2 changes: 2 additions & 0 deletions examples/timer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"name": "example-timer",
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"typescript": "^3.0.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-typescript": "*",
"@babel/preset-react": "*",
"@types/jest": "^23.1.1",
"babel-jest": "*",
"jest": "*"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"progress": "^2.0.0",
"promise": "^8.0.2",
"readable-stream": "^3.0.3",
"regenerator-runtime": "^0.12.1",
"resolve": "^1.4.0",
"rimraf": "^2.6.2",
"rollup": "^0.66.1",
Expand Down
47 changes: 1 addition & 46 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,6 @@ describe('babel-jest', () => {

expect(options.transform[0][0]).toBe(DEFAULT_JS_PATTERN);
expect(options.transform[0][1]).toEqual(require.resolve('babel-jest'));
expect(options.setupFiles).toEqual([
path.sep +
'node_modules' +
path.sep +
'regenerator-runtime' +
path.sep +
'runtime',
]);
});

it('uses babel-jest if babel-jest is explicitly specified in a custom transform options', () => {
Expand All @@ -762,38 +754,6 @@ describe('babel-jest', () => {

expect(options.transform[0][0]).toBe(customJSPattern);
expect(options.transform[0][1]).toEqual(require.resolve('babel-jest'));
expect(options.setupFiles).toEqual([
path.sep +
'node_modules' +
path.sep +
'regenerator-runtime' +
path.sep +
'runtime',
]);
});

it('uses regenerator if babel-jest is explicitly specified', () => {
const ROOT_DIR = '<rootDir>' + path.sep;

const {options} = normalize(
{
rootDir: '/root',
transform: {
[DEFAULT_JS_PATTERN]:
ROOT_DIR + Resolver.findNodeModule('babel-jest'),
},
},
{},
);

expect(options.setupFiles).toEqual([
path.sep +
'node_modules' +
path.sep +
'regenerator-runtime' +
path.sep +
'runtime',
]);
});
});

Expand Down Expand Up @@ -1188,12 +1148,7 @@ describe('preset without setupFiles', () => {
);

expect(options).toEqual(
expect.objectContaining({
setupFiles: [
'/node_modules/regenerator-runtime/runtime',
'/node_modules/a',
],
}),
expect.objectContaining({setupFiles: ['/node_modules/a']}),
);
});
});
Expand Down
16 changes: 2 additions & 14 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ const setupBabelJest = (options: InitialOptions) => {
[DEFAULT_JS_PATTERN]: babelJest,
};
}

return babelJest;
};

const normalizeCollectCoverageOnlyFrom = (
Expand Down Expand Up @@ -446,7 +444,8 @@ export default function normalize(options: InitialOptions, argv: Argv) {
options.coverageDirectory = path.resolve(options.rootDir, 'coverage');
}

const babelJest = setupBabelJest(options);
setupBabelJest(options);

const newOptions: $Shape<
DefaultOptions & ProjectConfig & GlobalConfig,
> = (Object.assign({}, DEFAULT_CONFIG): any);
Expand Down Expand Up @@ -774,17 +773,6 @@ export default function normalize(options: InitialOptions, argv: Argv) {

newOptions.maxWorkers = getMaxWorkers(argv);

if (babelJest) {
const regeneratorRuntimePath = Resolver.findNodeModule(
'regenerator-runtime/runtime',
{basedir: options.rootDir, resolver: newOptions.resolver},
);

if (regeneratorRuntimePath) {
newOptions.setupFiles.unshift(regeneratorRuntimePath);
}
}

if (newOptions.testRegex.length && options.testMatch) {
throw createConfigError(
` Configuration options ${chalk.bold('testMatch')} and` +
Expand Down
Loading