test: invoke Jest in CI mode (#803)

Summary:
CI mode prevents Jest from automatically writing snapshots, and also
causes obsolete snapshots to be an error instead of a warning. This is
consistent with the behavior on Travis, where the `CI=1` environment
variable is set. It should thus be the default when running `yarn test`
(but not `yarn unit`).

Test Plan:
Add a file `src/foo.test.js`:

```js
// @flow
describe("foo", () => {
  it("bar", () => {
    expect("baz").toMatchSnapshot();
  });
});
```

Note that `yarn test` fails with the message, “new snapshot was not
written”.

Revert this change, then re-run `yarn test`; note that it passes,
writing a snapshot.

Then, reinstate this change and delete `src/foo.test.js`. Note that
running `yarn test` fails, due to an obsolete snapshot. Revert the
change again, and watch `yarn test` pass despite the obsolete snapshot.

Finally, remove the snapshot. :-)

wchargin-branch: test-jest-ci
This commit is contained in:
William Chargin 2018-09-06 20:45:16 -07:00 committed by GitHub
parent 2d4acf62c5
commit 4b0693e2a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -68,7 +68,7 @@ function makeTasks(mode /*: "BASIC" | "FULL" */) {
}, },
{ {
id: "unit", id: "unit",
cmd: ["npm", "run", "--silent", "unit"], cmd: ["npm", "run", "--silent", "unit", "--", "--ci"],
deps: [], deps: [],
}, },
{ {