diff --git a/e2e/custom-resolver/__tests__/customResolver.test.js b/e2e/custom-resolver/__tests__/customResolver.test.js index 9e6911f35f62..12e829730062 100644 --- a/e2e/custom-resolver/__tests__/customResolver.test.js +++ b/e2e/custom-resolver/__tests__/customResolver.test.js @@ -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'); diff --git a/e2e/custom-resolver/fakeRegenerator.js b/e2e/custom-resolver/fakeRegenerator.js deleted file mode 100644 index 50aa61798eeb..000000000000 --- a/e2e/custom-resolver/fakeRegenerator.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - -global.fakeRegeneratorInjected = true; diff --git a/e2e/custom-resolver/resolver.js b/e2e/custom-resolver/resolver.js index f854ce959e6b..4db6cbf41c39 100644 --- a/e2e/custom-resolver/resolver.js +++ b/e2e/custom-resolver/resolver.js @@ -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); diff --git a/examples/async/.babelrc.js b/examples/async/.babelrc.js index 0cf578eefca3..2637b0295844 100644 --- a/examples/async/.babelrc.js +++ b/examples/async/.babelrc.js @@ -1,11 +1,4 @@ module.exports = { - plugins: [ - [ - '@babel/plugin-transform-runtime', - { - regenerator: true, - }, - ], - ], + plugins: ['@babel/plugin-transform-runtime'], presets: ['@babel/preset-env'], }; diff --git a/examples/snapshot/package.json b/examples/snapshot/package.json index 88af079bfe9d..4ae7ef555ff9 100644 --- a/examples/snapshot/package.json +++ b/examples/snapshot/package.json @@ -10,8 +10,7 @@ "@babel/preset-react": "*", "babel-jest": "*", "jest": "*", - "react-test-renderer": "*", - "regenerator-runtime": "*" + "react-test-renderer": "*" }, "scripts": { "test": "jest" diff --git a/package.json b/package.json index c3dea7526112..ce87840fd892 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@babel/preset-flow": "^7.0.0", "@babel/preset-react": "^7.0.0", "@babel/register": "^7.0.0", + "@babel/runtime": "^7.0.0", "ansi-regex": "^4.0.0", "ansi-styles": "^3.2.0", "babel-eslint": "^9.0.0", @@ -52,7 +53,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", diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 6cc0a5134faf..2df3aea4cf77 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -10,7 +10,8 @@ "main": "build/index.js", "dependencies": { "babel-plugin-istanbul": "^5.1.0", - "babel-preset-jest": "^23.2.0" + "babel-preset-jest": "^23.2.0", + "@babel/plugin-transform-runtime": "^7.2.0" }, "devDependencies": { "@babel/core": "^7.1.0" diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index 153da5b636c9..8237db9a57b3 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -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', () => { @@ -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 = '' + 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', - ]); }); }); @@ -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']}), ); }); }); diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index e820158e1157..4e8290ff8adb 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -170,8 +170,6 @@ const setupBabelJest = (options: InitialOptions) => { [DEFAULT_JS_PATTERN]: babelJest, }; } - - return babelJest; }; const normalizeCollectCoverageOnlyFrom = ( @@ -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); @@ -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` + diff --git a/yarn.lock b/yarn.lock index 170690cb062c..0ae58fd32687 100644 --- a/yarn.lock +++ b/yarn.lock @@ -630,7 +630,17 @@ dependencies: regenerator-transform "^0.13.3" -"@babel/plugin-transform-runtime@*", "@babel/plugin-transform-runtime@^7.0.0": +"@babel/plugin-transform-runtime@*", "@babel/plugin-transform-runtime@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.2.0.tgz#566bc43f7d0aedc880eaddbd29168d0f248966ea" + integrity sha512-jIgkljDdq4RYDnJyQsiWbdvGeei/0MOTtSHKO/rfbd/mXBxNpdlulMx49L0HQ4pug1fXannxoqCI+fYSle9eSw== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + resolve "^1.8.1" + semver "^5.5.1" + +"@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== @@ -797,9 +807,9 @@ source-map-support "^0.5.9" "@babel/runtime@*", "@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== + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.2.0.tgz#b03e42eeddf5898e00646e4c840fa07ba8dcad7f" + integrity sha512-oouEibCbHMVdZSDlJBO6bZmID/zA/G/Qx3H1d3rSNPTD+L8UNKvCat7aKWSJ74zYbm5zWGh0GQN0hKj8zYFTCg== dependencies: regenerator-runtime "^0.12.0" @@ -11299,11 +11309,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" @@ -11314,6 +11319,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"