Skip to content

Commit

Permalink
Merge branch 'master' into set-force-color-0-in-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Jul 3, 2018
2 parents 2f7b49c + 6edbeb1 commit 803f045
Show file tree
Hide file tree
Showing 33 changed files with 241 additions and 106 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"transform-flow-strip-types",
"transform-es2015-destructuring",
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
"transform-es2015-spread",
"transform-async-to-generator",
"transform-strict-mode",
Expand Down
46 changes: 28 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,31 @@ aliases:

- &deploy
command: |
# Deploy Jest website using Docusaurus bot
git config --global user.email "docusaurus-bot@users.noreply.github.com"
git config --global user.name "Website Deployment Script"
echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc
# install Docusaurus and generate file of English strings
yarn && cd website && yarn write-translations
# crowdin install
sudo apt-get update
sudo apt-get install default-jre rsync
wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
sudo dpkg -i crowdin.deb
sleep 5
# translations upload/download
yarn crowdin-upload
yarn crowdin-download
# build and publish website
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
# Deploy Jest website using Docusaurus bot
git config --global user.email "docusaurus-bot@users.noreply.github.com"
git config --global user.name "Website Deployment Script"
echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc
# install Docusaurus and generate file of English strings
yarn && cd website && yarn write-translations
# crowdin install
sudo apt-get update
sudo apt-get install default-jre rsync
wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
sudo dpkg -i crowdin.deb
sleep 5
# translations upload/download
yarn crowdin-upload
yarn crowdin-download
# build and publish website
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
else
echo "Skipping deploy."
fi
- &filter-ignore-gh-pages
branches:
ignore: gh-pages

version: 2
jobs:
Expand Down Expand Up @@ -125,6 +133,7 @@ jobs:
working_directory: ~/jest
docker:
- image: circleci/node:8
resource_class: large
steps:
- checkout
- restore-cache: *restore-cache
Expand All @@ -143,4 +152,5 @@ workflows:
- test-node-10
- test-jest-circus
- test-browser
- test-and-deploy-website
- test-and-deploy-website:
filters: *filter-ignore-gh-pages
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

### Features

- `[jest-cli]` Allow watch plugin to be configured ([#6603](https://github.com/facebook/jest/pull/6603))
- `[jest-snapshot]` Introduce `toMatchInlineSnapshot` and `toThrowErrorMatchingInlineSnapshot` matchers ([#6380](https://github.com/facebook/jest/pull/6380))

### Fixes

- `[jest-regex-util]` Improve handling already escaped path separators on Windows ([#6523](https://github.com/facebook/jest/pull/6523))
- `[jest-cli]` Fix `testNamePattern` value with interactive snapshots ([#6579](https://github.com/facebook/jest/pull/6579))
- `[jest-cli]` Fix enter to interrupt watch mode ([#6601](https://github.com/facebook/jest/pull/6601))

### Chore & Maintenance

- `[website]` Switch domain to https://jestjs.io ([#6549](https://github.com/facebook/jest/pull/6549))
- `[tests]` Improve stability of `yarn test` on Windows ([#6534](https://github.com/facebook/jest/pull/6534))
- `[*]` Transpile object shorthand into Node 4 compatible syntax ([#6582](https://github.com/facebook/jest/pull/6582))
- `[tests]` Free tests from the dependency on value of FORCE_COLOR ([#6585](https://github.com/facebook/jest/pull/6585/files))

## 23.2.0
Expand Down
2 changes: 1 addition & 1 deletion TestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const DEFAULT_PROJECT_CONFIG: ProjectConfig = {
modulePathIgnorePatterns: [],
modulePaths: [],
name: 'test_name',
prettier: 'prettier',
prettierPath: 'prettier',
resetMocks: false,
resetModules: false,
resolver: null,
Expand Down
6 changes: 6 additions & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ Allows the test suite to pass when no files are found.

Run tests from one or more projects.

### `--reporters`

Run tests with specified reporters. [Reporter options](configuration#reporters-array-modulename-modulename-options) are not available via CLI. Example with multiple reporters:

`jest --reporters="default" --reporters="jest-junit"`

### `--runInBand`

Alias: `-i`. Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests. This can be useful for debugging.
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Presets may also be relative filesystem paths.
}
```

### `prettier` [string]
### `prettierPath` [string]

Default: `'prettier'`

Expand Down
2 changes: 1 addition & 1 deletion docs/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Inline snapshots behave identically to external snapshots (`.snap` files), excep

> Inline snapshots are powered by [Prettier](https://prettier.io). To use inline snapshots you must have `prettier` installed in your project. Your Prettier configuration will be respected when writing to test files.
>
> If you have `prettier` installed in a location where Jest can't find it, you can tell Jest how to find it using the [`"prettier"`](./Configuration.md#prettier-string) configuration property.
> If you have `prettier` installed in a location where Jest can't find it, you can tell Jest how to find it using the [`"prettierPath"`](./Configuration.md#prettierpath-string) configuration property.
**Example:**

Expand Down
33 changes: 33 additions & 0 deletions docs/WatchPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,36 @@ class MyWatchPlugin {
}
}
```

## Customization

Plugins can be customized via your Jest configuration.

```javascript
// jest.config.js
module.exports = {
// ...
watchPlugins: [
[
'path/to/yourWatchPlugin',
{
key: 'k', // <- your custom key
prompt: 'show a custom prompt',
},
],
],
};
```

Recommended config names:

- `key`: Modifies the plugin key.
- `prompt`: Allows user to customize the text in the plugin prompt.

If the user provided a custom configuration, it will be passed as an argument to the plugin constructor.

```javascript
class MyWatchPlugin {
constructor({config}) {}
}
```
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/show_config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
\\"moduleNameMapper\\": {},
\\"modulePathIgnorePatterns\\": [],
\\"name\\": \\"[md5 hash]\\",
\\"prettier\\": null,
\\"prettierPath\\": null,
\\"resetMocks\\": false,
\\"resetModules\\": false,
\\"resolver\\": null,
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/test_environment_async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const os = require('os');
const runJest = require('../runJest');
const {cleanup} = require('../Utils');

const DIR = os.tmpdir() + '/jest';
const DIR = os.tmpdir() + '/jest-test-environment';

beforeEach(() => cleanup(DIR));
afterAll(() => cleanup(DIR));
Expand Down
2 changes: 1 addition & 1 deletion e2e/test-environment-async/TestEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const os = require('os');
const mkdirp = require('mkdirp');
const JSDOMEnvironment = require('jest-environment-jsdom');

const DIR = os.tmpdir() + '/jest';
const DIR = os.tmpdir() + '/jest-test-environment';

class TestEnvironment extends JSDOMEnvironment {
constructor(config) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-es2015-parameters": "^6.23.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-flow-strip-types": "^6.18.0",
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export const initialize = ({
const {expand, updateSnapshot} = globalConfig;
const snapshotState = new SnapshotState(testPath, {
expand,
getPrettier: () => (config.prettier ? localRequire(config.prettier) : null),
getPrettier: () =>
config.prettierPath ? localRequire(config.prettierPath) : null,
updateSnapshot,
});
setState({snapshotState, testPath});
Expand Down
15 changes: 15 additions & 0 deletions packages/jest-cli/src/__tests__/__snapshots__/watch.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ Watch Usage
]
`;

exports[`Watch mode flows allows WatchPlugins to be configured 1`] = `
Array [
"
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press k to filter with a custom prompt.
› Press Enter to trigger a test run.
",
]
`;

exports[`Watch mode flows allows WatchPlugins to override internal plugins 1`] = `
Array [
"
Expand Down
36 changes: 18 additions & 18 deletions packages/jest-cli/src/__tests__/snapshot_interactive_mode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to run process the first file', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -53,8 +53,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to abort', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -66,8 +66,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to reset', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -85,15 +85,15 @@ describe('SnapshotInteractiveMode', () => {
});

test('press ENTER trigger a run', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];
instance.run(assertions, mockCallback);
instance.put(KEYS.ENTER);
expect(mockCallback).toHaveBeenCalledTimes(2);
expect(mockCallback).toHaveBeenCalledWith(assertions[0], false);
});

test('skip 1 test, then restart', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand All @@ -113,7 +113,7 @@ describe('SnapshotInteractiveMode', () => {
});

test('skip 1 test, then quit', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('SnapshotInteractiveMode', () => {
instance.updateWithResults({snapshot: {failure: true}});
});

const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand All @@ -162,8 +162,8 @@ describe('SnapshotInteractiveMode', () => {

test('skip 2 tests, then finish and restart', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];
instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand Down Expand Up @@ -207,8 +207,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down Expand Up @@ -255,8 +255,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down Expand Up @@ -303,8 +303,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down
Loading

0 comments on commit 803f045

Please sign in to comment.