forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jest-each-heading-validation
* master: (30 commits) chore: verify TS project references are correct (jestjs#10941) chore(deps): bump actions/setup-node from v2.1.2 to v2.1.3 (jestjs#10940) docs: Rectify typo in tutorialReactNative (jestjs#10930) chore: patch react-native jest preprocessor to avoid warning Ensure `toContain` only accepts strings when `received` is a string (jestjs#10929) chore: update lockfile after publish v27.0.0-next.2 Document and test custom, async, inline snapshot matcher (jestjs#10922) feat(transform): pass config options through to transformer (jestjs#10926) chore: bump eslint-config-prettier chore: run prettier using eslint chore: update lockfile after publish v27.0.0-next.1 fix: move binary file declaration from runtime to repl (jestjs#10925) chore(test-result): remove deprecated `sourcemap` property (jestjs#10355) chore: remove mapCoverage remainings; remove deprecated CLI options test (jestjs#9968) refactor(jest-runtime,jest-transform): add readonly for some class fields (jestjs#10918) chore: ensure single environment package as well chore: fix failing tests (jestjs#10924) chore: fix lint warning ...
- Loading branch information
Showing
131 changed files
with
1,314 additions
and
847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ jobs: | |
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
ubuntu-latest-node-12.x-yarn- | ||
- uses: actions/[email protected].2 | ||
- uses: actions/[email protected].3 | ||
with: | ||
node-version: 12.x | ||
- name: install | ||
|
@@ -76,7 +76,7 @@ jobs: | |
restore-keys: | | ||
${{ runner.os }}-node-${{ matrix.node-version }}-yarn- | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected].2 | ||
uses: actions/[email protected].3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: install | ||
|
@@ -117,7 +117,7 @@ jobs: | |
restore-keys: | | ||
${{ runner.os }}-node-14.x-yarn- | ||
- name: Use Node.js 14.x | ||
uses: actions/[email protected].2 | ||
uses: actions/[email protected].3 | ||
with: | ||
node-version: 14.x | ||
- name: install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
e2e/__tests__/__snapshots__/customInlineSnapshotMatchers.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`works with custom inline snapshot matchers 1`] = ` | ||
FAIL __tests__/asynchronous.test.js | ||
✕ new async, inline snapshots | ||
✕ mismatching async, inline snapshots | ||
● new async, inline snapshots | ||
expect(received).toMatchInlineSnapshot() | ||
Snapshot name: \`new async, inline snapshots 1\` | ||
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot. | ||
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default. | ||
Received: "result #1" | ||
20 | | ||
21 | test('new async, inline snapshots', async () => { | ||
> 22 | await expect(async () => 'result #1').toMatchObservationInlineSnapshot(); | ||
| ^ | ||
23 | await expect(async () => 'result #2').toMatchObservationInlineSnapshot(); | ||
24 | }); | ||
25 | | ||
at Object.toMatchObservationInlineSnapshot (__tests__/asynchronous.test.js:22:41) | ||
● new async, inline snapshots | ||
expect(received).toMatchInlineSnapshot() | ||
Snapshot name: \`new async, inline snapshots 2\` | ||
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot. | ||
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default. | ||
Received: "result #2" | ||
21 | test('new async, inline snapshots', async () => { | ||
22 | await expect(async () => 'result #1').toMatchObservationInlineSnapshot(); | ||
> 23 | await expect(async () => 'result #2').toMatchObservationInlineSnapshot(); | ||
| ^ | ||
24 | }); | ||
25 | | ||
26 | test('mismatching async, inline snapshots', async () => { | ||
at Object.toMatchObservationInlineSnapshot (__tests__/asynchronous.test.js:23:41) | ||
● mismatching async, inline snapshots | ||
expect(received).toMatchInlineSnapshot(snapshot) | ||
Snapshot name: \`mismatching async, inline snapshots 1\` | ||
Snapshot: "result #?" | ||
Received: "result #1" | ||
25 | | ||
26 | test('mismatching async, inline snapshots', async () => { | ||
> 27 | await expect(async () => 'result #1').toMatchObservationInlineSnapshot( | ||
| ^ | ||
28 | \`"result #?"\`, | ||
29 | ); | ||
30 | await expect(async () => 'result #2').toMatchObservationInlineSnapshot( | ||
at Object.toMatchObservationInlineSnapshot (__tests__/asynchronous.test.js:27:41) | ||
● mismatching async, inline snapshots | ||
expect(received).toMatchInlineSnapshot(snapshot) | ||
Snapshot name: \`mismatching async, inline snapshots 2\` | ||
Snapshot: "result #?" | ||
Received: "result #2" | ||
28 | \`"result #?"\`, | ||
29 | ); | ||
> 30 | await expect(async () => 'result #2').toMatchObservationInlineSnapshot( | ||
| ^ | ||
31 | \`"result #?"\`, | ||
32 | ); | ||
33 | }); | ||
at Object.toMatchObservationInlineSnapshot (__tests__/asynchronous.test.js:30:41) | ||
› 4 snapshots failed. | ||
Snapshot Summary | ||
› 4 snapshots failed from 1 test suite. Inspect your code changes or re-run jest with \`-u\` to update them. | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
import {extractSummary} from '../Utils'; | ||
import runJest from '../runJest'; | ||
|
||
test('works with custom inline snapshot matchers', () => { | ||
const {stderr} = runJest('custom-inline-snapshot-matchers', [ | ||
// Prevent adding new snapshots or rather changing the test. | ||
'--ci', | ||
'asynchronous.test.js', | ||
]); | ||
|
||
let {rest} = extractSummary(stderr); | ||
|
||
rest = rest | ||
.split('\n') | ||
.filter(line => line.indexOf('at Error (native)') < 0) | ||
.join('\n'); | ||
|
||
expect(wrap(rest)).toMatchSnapshot(); | ||
}); |
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
e2e/custom-inline-snapshot-matchers/__tests__/asynchronous.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const {toMatchInlineSnapshot} = require('jest-snapshot'); | ||
|
||
expect.extend({ | ||
async toMatchObservationInlineSnapshot(fn, ...args) { | ||
this.error = new Error(); | ||
// This specific behavior can be implemented without a custom matcher. | ||
// In a real example one might want to observe some global value that `fn()` is affecting. | ||
// The difference between before and after `fn()` might then be persisted as a snapshot. | ||
const result = await fn(); | ||
|
||
return toMatchInlineSnapshot.call(this, result, ...args); | ||
}, | ||
}); | ||
|
||
test('new async, inline snapshots', async () => { | ||
await expect(async () => 'result #1').toMatchObservationInlineSnapshot(); | ||
await expect(async () => 'result #2').toMatchObservationInlineSnapshot(); | ||
}); | ||
|
||
test('mismatching async, inline snapshots', async () => { | ||
await expect(async () => 'result #1').toMatchObservationInlineSnapshot( | ||
`"result #?"`, | ||
); | ||
await expect(async () => 'result #2').toMatchObservationInlineSnapshot( | ||
`"result #?"`, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
Oops, something went wrong.