Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Jest's default options #5948

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
// ...
};
```

<AUTOGENERATED_TABLE_OF_CONTENTS>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new heading should be below the ToC, shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB tried, less readable

screen shot 2018-04-09 at 17 07 04


---
Expand Down
5 changes: 5 additions & 0 deletions packages/jest-config/src/__tests__/defaults.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {defaults} from '../index';

test('get configuration defaults', () => {
expect(defaults).toBeDefined();
});
1 change: 1 addition & 0 deletions packages/jest-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down