diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d9a4ff6785..26b428a56e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features +* `[jest-config]` Export Jest's default options + ([#5948](https://github.com/facebook/jest/pull/5948)) * `[jest-editor-support]` Move `coverage` to `ProjectWorkspace.collectCoverage` ([#5929](https://github.com/facebook/jest/pull/5929)) * `[jest-editor-support]` Add `coverage` option to runner diff --git a/docs/Configuration.md b/docs/Configuration.md index 9ddead5d548c..10ef341fcd07 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -44,6 +44,20 @@ These options let you control Jest's behavior in your `package.json` file. The Jest philosophy is to work great by default, but sometimes you just need more configuration power. +### Defaults + +You can retrieve Jest's default options to expand them if needed: + +```js +// jest.config.js +const {defaults} = require('jest-config'); +module.exports = { + // ... + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], + // ... +}; +``` + --- diff --git a/packages/jest-config/src/__tests__/defaults.test.js b/packages/jest-config/src/__tests__/defaults.test.js new file mode 100644 index 000000000000..bfd3a833e445 --- /dev/null +++ b/packages/jest-config/src/__tests__/defaults.test.js @@ -0,0 +1,5 @@ +import {defaults} from '../index'; + +test('get configuration defaults', () => { + expect(defaults).toBeDefined(); +}); diff --git a/packages/jest-config/src/index.js b/packages/jest-config/src/index.js index 88afaedfb6c4..2d61877849c7 100644 --- a/packages/jest-config/src/index.js +++ b/packages/jest-config/src/index.js @@ -25,6 +25,7 @@ export {getTestEnvironment, isJSONString} from './utils'; export {default as normalize} from './normalize'; export {default as deprecationEntries} from './deprecated'; export {replaceRootDirInPath} from './utils'; +export {default as defaults} from './defaults'; export function readConfig( argv: Argv,