Skip to content

Commit

Permalink
expect: fix regression in toThrow for message prop and asymmetric mat…
Browse files Browse the repository at this point in the history
…chers (#7697)
  • Loading branch information
pedrottimark authored and SimenB committed Jan 25, 2019
1 parent 6081f7a commit 634e5a5
Show file tree
Hide file tree
Showing 4 changed files with 525 additions and 58 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
- `[babel-plugin-jest-hoist]` Ignore TS type annotations when looking for out-of-scope references ([#7641](https://github.com/facebook/jest/pull/7641))
- `[jest-config]` Add name to project if one does not exist to pick correct resolver ([#5862](https://github.com/facebook/jest/pull/5862))
- `[jest-runtime]` Pass `watchPathIgnorePatterns` to Haste instance ([#7585](https://github.com/facebook/jest/pull/7585))
- `[jest-runtime]` Resolve mock files via Haste when using `require.resolve` ([#7687](https://github.com/facebook/jest/pull/7585))
- `[jest-runtime]` Resolve mock files via Haste when using `require.resolve` ([#7687](https://github.com/facebook/jest/pull/7687))

### Chore & Maintenance

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,91 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`.toThrow() asymmetric any-Class fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Any<Err2></>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric any-Class fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Any<Err></>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric anything fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Anything</>

Thrown value: <red>null</>
"
`;

exports[`.toThrow() asymmetric anything fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Anything</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric no-symbol fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>{\\"asymmetricMatch\\": [Function asymmetricMatch]}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric no-symbol fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>{\\"asymmetricMatch\\": [Function asymmetricMatch]}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric objectContaining fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>ObjectContaining {\\"name\\": \\"NotError\\"}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() asymmetric objectContaining fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>ObjectContaining {\\"name\\": \\"Error\\"}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() error class did not throw at all 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expand Down Expand Up @@ -39,6 +125,22 @@ Received message: <red>\\"apple\\"</>
<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrow() error-message fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrow<dim>(</><green>expected</><dim>)</>

Expected message: <green>\\"apple\\"</>
Received message: <red>\\"banana\\"</>
"
`;

exports[`.toThrow() error-message fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>(</><green>expected</><dim>)</>

Expected message: <green>\\"apple\\"</>
Received message: <red>\\"apple\\"</>
"
`;

exports[`.toThrow() expected is undefined threw, but should not have (non-error falsey) 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrow<dim>()</>

Expand Down Expand Up @@ -174,6 +276,92 @@ Received value: <red>\\"Internal Server Error\\"</>
"
`;

exports[`.toThrowError() asymmetric any-Class fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Any<Err2></>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric any-Class fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Any<Err></>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric anything fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Anything</>

Thrown value: <red>null</>
"
`;

exports[`.toThrowError() asymmetric anything fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>Anything</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric no-symbol fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>{\\"asymmetricMatch\\": [Function asymmetricMatch]}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric no-symbol fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>{\\"asymmetricMatch\\": [Function asymmetricMatch]}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric objectContaining fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>ObjectContaining {\\"name\\": \\"NotError\\"}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() asymmetric objectContaining fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected asymmetric matcher: <green>ObjectContaining {\\"name\\": \\"Error\\"}</>

Received name: <red>\\"Error\\"</>
Received message: <red>\\"apple\\"</>

<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() error class did not throw at all 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expand Down Expand Up @@ -213,6 +401,22 @@ Received message: <red>\\"apple\\"</>
<dim>at jestExpect (</>packages/expect/src/__tests__/toThrowMatchers-test.js<dim>:24:74)</>"
`;

exports[`.toThrowError() error-message fail isNot false 1`] = `
"<dim>expect(</><red>received</><dim>).</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected message: <green>\\"apple\\"</>
Received message: <red>\\"banana\\"</>
"
`;

exports[`.toThrowError() error-message fail isNot true 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>(</><green>expected</><dim>)</>

Expected message: <green>\\"apple\\"</>
Received message: <red>\\"apple\\"</>
"
`;

exports[`.toThrowError() expected is undefined threw, but should not have (non-error falsey) 1`] = `
"<dim>expect(</><red>received</><dim>).</>not<dim>.</>toThrowError<dim>()</>

Expand Down
Loading

0 comments on commit 634e5a5

Please sign in to comment.