Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -6,6 +6,7 @@

### Fixes

- `[babel-jest]` Take a regression bug for createTransformer ([#9955](https://github.com/facebook/jest/pull/9955))
- `[jest-circus, jest-console, jest-jasmine2, jest-reporters, jest-util, pretty-format]` Fix time durating formatting and consolidate time formatting code ([#9765](https://github.com/facebook/jest/pull/9765))
- `[jest-circus]` [**BREAKING**] Fail tests if a test takes a done callback and have return values ([#9129](https://github.com/facebook/jest/pull/9129))
- `[jest-circus]` [**BREAKING**] Throw a proper error if a test / hook is defined asynchronously ([#8096](https://github.com/facebook/jest/pull/8096))
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/transform.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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:178:13)
at loadBabelConfig (../../../packages/babel-jest/build/index.js:180:13)
`;

exports[`babel-jest instruments only specific files and collects coverage 1`] = `
Expand Down
18 changes: 18 additions & 0 deletions packages/babel-jest/src/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,21 @@ describe('caller option correctly merges from defaults and options', () => {
);
});
});

test('can pass null to createTransformer', () => {
const transformer = babelJest.createTransformer(null);
transformer.process(sourceString, 'dummy_path.js', makeProjectConfig(), {
instrument: false,
});

expect(loadPartialConfig).toHaveBeenCalledTimes(1);
expect(loadPartialConfig).toHaveBeenCalledWith(
expect.objectContaining({
caller: {
name: 'babel-jest',
supportsDynamicImport: false,
supportsStaticESM: false,
},
}),
);
});
3 changes: 2 additions & 1 deletion packages/babel-jest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ interface BabelJestTransformOptions extends TransformOptions {
}

const createTransformer = (
inputOptions: TransformOptions = {},
userOptions?: TransformOptions | null,
): BabelJestTransformer => {
const inputOptions: TransformOptions = userOptions ?? {};
const options: BabelJestTransformOptions = {
...inputOptions,
caller: {
Expand Down