diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bddfa129c71..2305497c06f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - `[jest-transform]` Add support for transformers written in ESM ([#11163](https://github.com/facebook/jest/pull/11163)) - `[jest-transform]` [**BREAKING**] Do not export `ScriptTransformer` class, instead export the async function `createScriptTransformer` ([#11163](https://github.com/facebook/jest/pull/11163)) - `[jest-transform]` Async code transformations ([#9889](https://github.com/facebook/jest/pull/9889)) +- `[jest-transform]` Support transpiled transformers ([#11193](https://github.com/facebook/jest/pull/11193)) - `[jest-worker]` Add support for custom task queues and adds a `PriorityQueue` implementation. ([#10921](https://github.com/facebook/jest/pull/10921)) - `[jest-worker]` Add in-order scheduling policy to jest worker ([10902](https://github.com/facebook/jest/pull/10902)) @@ -73,6 +74,7 @@ - `[*]` [**BREAKING**] Add `exports` field to all `package.json`s ([#9921](https://github.com/facebook/jest/pull/9921)) - `[*]` Make it easier for Jest's packages to use the VM escape hatch ([#10824](https://github.com/facebook/jest/pull/10824)) - `[*]` [**BREAKING**] Remove deprecated `mapCoverage` ([#9968](https://github.com/facebook/jest/pull/9968)) +- `[babel-jest]` [**BREAKING**] Migrate to ESM ([#11193](https://github.com/facebook/jest/pull/11193)) - `[docs]` Correct example using `browser-resolve` ([#11140](https://github.com/facebook/jest/pull/11140)) - `[jest-config]` [**BREAKING**] Remove `enabledTestsMap` config, use `filter` instead ([#10787](https://github.com/facebook/jest/pull/10787)) - `[jest-console]` [**BREAKING**] Move `root` into `config` and take `GlobalConfig` as mandatory parameter for `getConsoleOutput` ([#10126](https://github.com/facebook/jest/pull/10126)) diff --git a/e2e/__tests__/__snapshots__/transform.test.ts.snap b/e2e/__tests__/__snapshots__/transform.test.ts.snap index a68d884e885c..c7310e6bfd8a 100644 --- a/e2e/__tests__/__snapshots__/transform.test.ts.snap +++ b/e2e/__tests__/__snapshots__/transform.test.ts.snap @@ -6,7 +6,7 @@ FAIL __tests__/ignoredFile.test.js babel-jest: Babel ignores __tests__/ignoredFile.test.js - make sure to include the file in Jest's transformIgnorePatterns as well. - at loadBabelConfig (../../../packages/babel-jest/build/index.js:190:13) + at loadBabelConfig (../../../packages/babel-jest/build/index.js:195:13) `; exports[`babel-jest instruments only specific files and collects coverage 1`] = ` diff --git a/e2e/transform/babel-jest-manual/transformer.js b/e2e/transform/babel-jest-manual/transformer.js index 597b36bc9ae5..016f7dd30d62 100644 --- a/e2e/transform/babel-jest-manual/transformer.js +++ b/e2e/transform/babel-jest-manual/transformer.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -const {createTransformer} = require('babel-jest'); +const {createTransformer} = require('babel-jest').default; module.exports = createTransformer({ presets: ['@babel/preset-flow'], diff --git a/packages/babel-jest/src/__tests__/index.ts b/packages/babel-jest/src/__tests__/index.ts index 445a50d8dec8..9d79de986d36 100644 --- a/packages/babel-jest/src/__tests__/index.ts +++ b/packages/babel-jest/src/__tests__/index.ts @@ -6,7 +6,7 @@ */ import {makeProjectConfig} from '@jest/test-utils'; -import babelJest = require('../index'); +import babelJest from '../index'; import {loadPartialConfig} from '../loadBabelConfig'; jest.mock('../loadBabelConfig', () => { diff --git a/packages/babel-jest/src/index.ts b/packages/babel-jest/src/index.ts index c0bff0b5d336..c7048c37a395 100644 --- a/packages/babel-jest/src/index.ts +++ b/packages/babel-jest/src/index.ts @@ -167,4 +167,4 @@ const transformer: SyncTransformer = { createTransformer, }; -export = transformer; +export default transformer; diff --git a/packages/jest-repl/src/__tests__/jest_repl.test.js b/packages/jest-repl/src/__tests__/jest_repl.test.js index b94a29b606c0..ebf51b028caf 100644 --- a/packages/jest-repl/src/__tests__/jest_repl.test.js +++ b/packages/jest-repl/src/__tests__/jest_repl.test.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. * */ -'use strict'; import {spawnSync} from 'child_process'; import path from 'path'; @@ -29,6 +28,7 @@ describe('Repl', () => { encoding: 'utf8', env: process.env, }); + expect(output.stderr.trim()).toBe(''); expect(output.stdout.trim()).toMatch(/›/); }); }); diff --git a/packages/jest-repl/src/cli/repl.ts b/packages/jest-repl/src/cli/repl.ts index 6dde9dad8c18..313b4988b36a 100644 --- a/packages/jest-repl/src/cli/repl.ts +++ b/packages/jest-repl/src/cli/repl.ts @@ -13,6 +13,7 @@ import * as repl from 'repl'; import {runInThisContext} from 'vm'; import type {SyncTransformer} from '@jest/transform'; import type {Config} from '@jest/types'; +import {interopRequireDefault} from 'jest-util'; // TODO: support async as well let transformer: SyncTransformer; @@ -77,7 +78,7 @@ if (jestProjectConfig.transform) { } } if (transformerPath) { - transformer = require(transformerPath); + transformer = interopRequireDefault(require(transformerPath)).default; if (typeof transformer.process !== 'function') { throw new TypeError( 'Jest: a transformer must export a `process` function.', diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index 7ce6c8d1554f..249f72b43188 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -255,7 +255,7 @@ class ScriptTransformer { let transformer: Transformer; try { - transformer = require(transformPath); + transformer = interopRequireDefault(require(transformPath)).default; } catch (error) { if (error.code === 'ERR_REQUIRE_ESM') { const configUrl = pathToFileURL(transformPath);