From ec820c39413754901db72aef8c27cb7cbbbea224 Mon Sep 17 00:00:00 2001 From: Jack Wu Date: Tue, 22 Dec 2020 21:41:45 +0800 Subject: [PATCH] fix(jest-config): move json behind ts (#10572) --- CHANGELOG.md | 1 + docs/Configuration.md | 2 +- e2e/__tests__/__snapshots__/showConfig.test.ts.snap | 2 +- .../jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap | 2 +- packages/jest-config/src/Defaults.ts | 2 +- packages/jest-config/src/__tests__/normalize.test.js | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9704759fe201..24ac70583279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - `[expect]` [**BREAKING**] Make `toContain` more strict with the received type ([#10119](https://github.com/facebook/jest/pull/10119) & [#10929](https://github.com/facebook/jest/pull/10929)) - `[jest-circus]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block [#10451](https://github.com/facebook/jest/issues/10451) - `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871)) +- `[jest-config]` [**BREAKING**] Change default file extension order by moving json behind ts and tsx ([10572](https://github.com/facebook/jest/pull/10572)) - `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638)) - `[jest-each]` [**BREAKING**] Ignore excess words in headings ([#8766](https://github.com/facebook/jest/pull/8766)) - `[jest-environment-jsdom]` Use inner realm’s `ArrayBuffer` constructor ([#10885](https://github.com/facebook/jest/pull/10885)) diff --git a/docs/Configuration.md b/docs/Configuration.md index a0efa9e2df23..d0f895117465 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -534,7 +534,7 @@ An array of directory names to be searched recursively up from the requiring mod ### `moduleFileExtensions` [array\] -Default: `["js", "json", "jsx", "ts", "tsx", "node"]` +Default: `["js", "jsx", "ts", "tsx", "json", "node"]` An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. diff --git a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap index 431d672a7322..f69f806a639c 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap @@ -29,10 +29,10 @@ exports[`--showConfig outputs config info and exits 1`] = ` ], "moduleFileExtensions": [ "js", - "json", "jsx", "ts", "tsx", + "json", "node" ], "moduleNameMapper": [], diff --git a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap index 05ec66cc3afc..40c0b966b6c1 100644 --- a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap +++ b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap @@ -191,10 +191,10 @@ module.exports = { // An array of file extensions your modules use // moduleFileExtensions: [ // \\"js\\", - // \\"json\\", // \\"jsx\\", // \\"ts\\", // \\"tsx\\", + // \\"json\\", // \\"node\\" // ], diff --git a/packages/jest-config/src/Defaults.ts b/packages/jest-config/src/Defaults.ts index 05d2b273a57b..22838a8cdbd5 100644 --- a/packages/jest-config/src/Defaults.ts +++ b/packages/jest-config/src/Defaults.ts @@ -37,7 +37,7 @@ const defaultOptions: Config.DefaultOptions = { maxConcurrency: 5, maxWorkers: '50%', moduleDirectories: ['node_modules'], - moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], + moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'], moduleNameMapper: {}, modulePathIgnorePatterns: [], noStackTrace: false, diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index c7fc0974bb3b..a9963f31f0f2 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -1605,10 +1605,10 @@ describe('moduleFileExtensions', () => { expect(options.moduleFileExtensions).toEqual([ 'js', - 'json', 'jsx', 'ts', 'tsx', + 'json', 'node', ]); });