-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [RFC] Inline Snapshots * Fix typechecking and refactor * Refactor State#match * Fix stacktrace regression * Remove unused argument * Fix support for property matchers * Fix tests after State#match refactor * Fix toThrowErrorMatchingInlineSnapshot * Optimize snapshot lookup * Support flow parser * Relax prettier version requirement * Fix TypeScript support * Support toMatchInlineSnapshot from external files * Add tests for saveInlineSnapshots() * Fix InlineSnapshot type definition * Escape backtick strings * Add test for escaping backticks * Code review fixes * Support project option for prettier Massive refactor, sorry I didn't split the commits * Refactor configuration * Fix typechecking * Set default value in cli/options * Fix typechecking * Write E2E tests for toMatchInlineSnapshot * Fix bad copy/paste * Parameterize saveInlineSnapshots test with jest-each * Write E2E tests for toThrowErrorMatchingInlineSnapshot * Write more aync tests * Skip currently failing test * Remove unused testPath property from State * Write documentation * Support async matchers * Fix links in docs
- Loading branch information
Showing
36 changed files
with
1,145 additions
and
74 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
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
115 changes: 115 additions & 0 deletions
115
e2e/__tests__/__snapshots__/to_match_inline_snapshot.test.js.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,115 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`basic support: initial write 1`] = ` | ||
"test('inline snapshots', () => | ||
expect({apple: 'original value'}).toMatchInlineSnapshot(\` | ||
Object { | ||
\\"apple\\": \\"original value\\", | ||
} | ||
\`)); | ||
" | ||
`; | ||
|
||
exports[`basic support: snapshot mismatch 1`] = ` | ||
"test('inline snapshots', () => | ||
expect({apple: 'updated value'}).toMatchInlineSnapshot(\` | ||
Object { | ||
\\"apple\\": \\"original value\\", | ||
} | ||
\`)); | ||
" | ||
`; | ||
|
||
exports[`basic support: snapshot passed 1`] = ` | ||
"test('inline snapshots', () => | ||
expect({apple: 'original value'}).toMatchInlineSnapshot(\` | ||
Object { | ||
\\"apple\\": \\"original value\\", | ||
} | ||
\`)); | ||
" | ||
`; | ||
|
||
exports[`basic support: snapshot updated 1`] = ` | ||
"test('inline snapshots', () => | ||
expect({apple: 'updated value'}).toMatchInlineSnapshot(\` | ||
Object { | ||
\\"apple\\": \\"updated value\\", | ||
} | ||
\`)); | ||
" | ||
`; | ||
|
||
exports[`handles property matchers: initial write 1`] = ` | ||
"test('handles property matchers', () => { | ||
expect({createdAt: new Date()}).toMatchInlineSnapshot( | ||
{createdAt: expect.any(Date)}, | ||
\` | ||
Object { | ||
\\"createdAt\\": Any<Date>, | ||
} | ||
\`, | ||
); | ||
}); | ||
" | ||
`; | ||
exports[`handles property matchers: snapshot failed 1`] = ` | ||
"test('handles property matchers', () => { | ||
expect({createdAt: \\"string\\"}).toMatchInlineSnapshot( | ||
{createdAt: expect.any(Date)}, | ||
\` | ||
Object { | ||
\\"createdAt\\": Any<Date>, | ||
} | ||
\`, | ||
); | ||
}); | ||
" | ||
`; | ||
exports[`handles property matchers: snapshot passed 1`] = ` | ||
"test('handles property matchers', () => { | ||
expect({createdAt: new Date()}).toMatchInlineSnapshot( | ||
{createdAt: expect.any(Date)}, | ||
\` | ||
Object { | ||
\\"createdAt\\": Any<Date>, | ||
} | ||
\`, | ||
); | ||
}); | ||
" | ||
`; | ||
exports[`handles property matchers: snapshot updated 1`] = ` | ||
"test('handles property matchers', () => { | ||
expect({createdAt: 'string'}).toMatchInlineSnapshot( | ||
{createdAt: expect.any(String)}, | ||
\` | ||
Object { | ||
\\"createdAt\\": Any<String>, | ||
} | ||
\`, | ||
); | ||
}); | ||
" | ||
`; | ||
exports[`supports async matchers 1`] = ` | ||
"test('inline snapshots', async () => { | ||
expect(Promise.resolve('success')).resolves.toMatchInlineSnapshot( | ||
\`\\"success\\"\`, | ||
); | ||
expect(Promise.reject('fail')).rejects.toMatchInlineSnapshot(\`\\"fail\\"\`); | ||
}); | ||
" | ||
`; | ||
exports[`supports async tests 1`] = ` | ||
"test('inline snapshots', async () => { | ||
await 'next tick'; | ||
expect(42).toMatchInlineSnapshot(\`42\`); | ||
}); | ||
" | ||
`; |
28 changes: 28 additions & 0 deletions
28
e2e/__tests__/__snapshots__/to_throw_error_matching_inline_snapshot.test.js.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,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should support rejecting promises 1`] = ` | ||
"test('should support rejecting promises', async () => { | ||
await expect( | ||
Promise.reject(new Error('octopus')), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(\`\\"octopus\\"\`); | ||
}); | ||
" | ||
`; | ||
exports[`updates existing snapshot: updated snapshot 1`] = ` | ||
"test('updates existing snapshot', () => { | ||
expect(() => { | ||
throw new Error('apple'); | ||
}).toThrowErrorMatchingInlineSnapshot(\`\\"apple\\"\`); | ||
}); | ||
" | ||
`; | ||
exports[`works fine when function throws error: initial write 1`] = ` | ||
"test('works fine when function throws error', () => { | ||
expect(() => { | ||
throw new Error('apple'); | ||
}).toThrowErrorMatchingInlineSnapshot(\`\\"apple\\"\`); | ||
}); | ||
" | ||
`; |
Oops, something went wrong.