From 69df9db0e8efe82b7459cd249fcdf45296bfeac3 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Mon, 9 Apr 2018 10:33:25 +0200 Subject: [PATCH 1/3] Export Jest's default options --- docs/Configuration.md | 14 ++++++++++++++ .../jest-config/src/__tests__/defaults.test.js | 5 +++++ packages/jest-config/src/index.js | 1 + 3 files changed, 20 insertions(+) create mode 100644 packages/jest-config/src/__tests__/defaults.test.js diff --git a/docs/Configuration.md b/docs/Configuration.md index 9ddead5d548c..8c52970642b7 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').defaults; +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, From 01e08a6200ac0236c2a1ab312aab438b6e42f408 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Mon, 9 Apr 2018 17:08:35 +0200 Subject: [PATCH 2/3] Improve require('jest-config') --- docs/Configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 8c52970642b7..10ef341fcd07 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -50,7 +50,7 @@ You can retrieve Jest's default options to expand them if needed: ```js // jest.config.js -const defaults = require('jest-config').defaults; +const {defaults} = require('jest-config'); module.exports = { // ... moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], From 333e387e8a03ce31788d07f2936019e8ed7bb44b Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Mon, 9 Apr 2018 17:09:13 +0200 Subject: [PATCH 3/3] Add "Export Jest's default options" to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db3aa0fef0e5..299bd35508e9 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]` Add `coverage` option to runner ([#5836](https://github.com/facebook/jest/pull/5836)) * `[jest-haste-map]` Support extracting dynamic `import`s