Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
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
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'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fakeRegenerator can be removed now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was more of a PoC (and I'm too lazy to run the tests on multiple nodes, so opened this up so CI could run), we should close this and go for yours 🙂

]);
const exportedModules = new Map([['foo', 'foo'], ['bar', 'bar']]);

module.exports = (name, options) => {
const resolution = exportedModules.get(name);
Expand Down
2 changes: 0 additions & 2 deletions examples/async/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"version": "0.0.0",
"name": "example-async",
"devDependencies": {
"@babel/plugin-transform-runtime": "*",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this plugins is still used by the example, probably works because our deps have this plugins somewhere

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove it from the babel config, preset-env should be enough

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it then reports that regeneratorRuntime is not defined 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm that was because of the target missing

"@babel/preset-env": "*",
"@babel/runtime": "*",
"babel-jest": "*",
"jest": "*"
},
Expand Down
3 changes: 1 addition & 2 deletions examples/snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"@babel/preset-react": "*",
"babel-jest": "*",
"jest": "*",
"react-test-renderer": "*",
"regenerator-runtime": "*"
"react-test-renderer": "*"
},
"scripts": {
"test": "jest"
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
45 changes: 1 addition & 44 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 @@ -1189,10 +1149,7 @@ describe('preset without setupFiles', () => {

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

return babelJest;
};

const normalizeCollectCoverageOnlyFrom = (
Expand Down Expand Up @@ -437,7 +435,7 @@ 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 @@ -758,17 +756,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
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
dependencies:
regenerator-transform "^0.13.3"

"@babel/plugin-transform-runtime@*", "@babel/plugin-transform-runtime@^7.0.0":
"@babel/plugin-transform-runtime@^7.0.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.1.0.tgz#9f76920d42551bb577e2dc594df229b5f7624b63"
integrity sha512-WFLMgzu5DLQEah0lKTJzYb14vd6UiES7PTnXcvrPZ1VrwFeJ+mTbvr65fFAsXYMt2bIoOoC0jk76zY1S7HZjUg==
Expand Down Expand Up @@ -796,7 +796,7 @@
pirates "^4.0.0"
source-map-support "^0.5.9"

"@babel/runtime@*", "@babel/runtime@^7.0.0":
"@babel/runtime@^7.0.0":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3"
integrity sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==
Expand Down Expand Up @@ -11299,11 +11299,6 @@ regenerate@^1.4.0:
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==

regenerator-runtime@*, regenerator-runtime@^0.12.0, regenerator-runtime@^0.12.1:
version "0.12.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==

regenerator-runtime@^0.10.0:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
Expand All @@ -11314,6 +11309,11 @@ regenerator-runtime@^0.11.0, regenerator-runtime@^0.11.1:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==

regenerator-runtime@^0.12.0:
version "0.12.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==

regenerator-transform@^0.13.3:
version "0.13.3"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.3.tgz#264bd9ff38a8ce24b06e0636496b2c856b57bcbb"
Expand Down