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.
- Loading branch information
1 parent
d7316a8
commit fe06363
Showing
6 changed files
with
182 additions
and
124 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
85 changes: 76 additions & 9 deletions
85
packages/jest-matchers/src/__tests__/__snapshots__/toThrowMatchers-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 |
---|---|---|
@@ -1,17 +1,84 @@ | ||
exports[`.toThrowError() error class did not throw at all 1`] = `"Expected function to throw an error of type [32m\"Err\"[39m."`; | ||
exports[`.toThrowError() error class did not throw at all 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mtype[39m[2m)[22m | ||
exports[`.toThrowError() error class threw, but class did not match 1`] = `"Received [31m\"Err: apple\"[39m but expected Expected function to throw an error of type [32m\"Err2\"[39m."`; | ||
Expected the function to throw an error of type: | ||
[32m\"Err\"[39m | ||
But it didn\'t throw anything." | ||
`; | ||
|
||
exports[`.toThrowError() error class threw, but should not have 1`] = `"Received [31m\"Err: apple\"[39m but expected the function not to throw an error of type [32m\"Err\"[39m."`; | ||
exports[`.toThrowError() error class threw, but class did not match 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mtype[39m[2m)[22m | ||
exports[`.toThrowError() regexp did not throw at all 1`] = `"the function to throw an error matching [32m\"/apple/\"[39m."`; | ||
Expected the function to throw an error of type: | ||
[32m\"Err2\"[39m | ||
Instead, it threw: | ||
[31m\"Err: apple\"[39m" | ||
`; | ||
|
||
exports[`.toThrowError() regexp threw, but message did not match 1`] = `"Received [31m\"Error: apple\"[39m but expected the function to throw an error matching [32m\"/banana/\"[39m."`; | ||
exports[`.toThrowError() error class threw, but should not have 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).not.toThrowError([22m[32mtype[39m[2m)[22m | ||
exports[`.toThrowError() regexp threw, but should not have 1`] = `"Received [31m\"Error: apple\"[39m but expected the function not to throw an error matching [32m\"/apple/\"[39m."`; | ||
Expeced the function not to throw an error of type: | ||
[32m\"Err\"[39m | ||
But it threw: | ||
[31m\"Err: apple\"[39m" | ||
`; | ||
|
||
exports[`.toThrowError() strings did not throw at all 1`] = `"the function to throw an error matching [32m\"apple\"[39m."`; | ||
exports[`.toThrowError() invalid arguments 1`] = ` | ||
"Unexpected argument passed. Expected to get | ||
[32m\"\\\"string\\\"\"[39m, [32m\"\\\"Error type\\\"\"[39m or [32m\"\\\"regexp\\\"\"[39m. | ||
Got: | ||
[31m\"number\"[39m: [31m111[39m." | ||
`; | ||
|
||
exports[`.toThrowError() strings threw, but message did not match 1`] = `"Received [31m\"Error: apple\"[39m but expected the function to throw an error matching [32m\"banana\"[39m."`; | ||
exports[`.toThrowError() regexp did not throw at all 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mregexp[39m[2m)[22m | ||
exports[`.toThrowError() strings threw, but should not have 1`] = `"Received [31m\"Error: apple\"[39m but expected the function not to throw an error matching [32m\"apple\"[39m."`; | ||
Expected the function to throw an error matching: | ||
[32m\"/apple/\"[39m | ||
But it didn\'t throw anything." | ||
`; | ||
|
||
exports[`.toThrowError() regexp threw, but message did not match 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mregexp[39m[2m)[22m | ||
Expected the function to throw an error matching: | ||
[32m\"/banana/\"[39m | ||
Instead, it threw: | ||
[31m\"Error: apple\"[39m" | ||
`; | ||
|
||
exports[`.toThrowError() regexp threw, but should not have 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).not.toThrowError([22m[32mregexp[39m[2m)[22m | ||
Expeced the function not to throw an error matching: | ||
[32m\"/apple/\"[39m | ||
But it threw: | ||
[31m\"Error: apple\"[39m" | ||
`; | ||
|
||
exports[`.toThrowError() strings did not throw at all 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mstring[39m[2m)[22m | ||
Expected the function to throw an error matching: | ||
[32m\"apple\"[39m | ||
But it didn\'t throw anything." | ||
`; | ||
|
||
exports[`.toThrowError() strings threw, but message did not match 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).toThrowError([22m[32mstring[39m[2m)[22m | ||
Expected the function to throw an error matching: | ||
[32m\"banana\"[39m | ||
Instead, it threw: | ||
[31m\"Error: apple\"[39m" | ||
`; | ||
|
||
exports[`.toThrowError() strings threw, but should not have 1`] = ` | ||
"[2mexpect([22m[31mfunction[39m[2m).not.toThrowError([22m[32mstring[39m[2m)[22m | ||
Expeced the function not to throw an error matching: | ||
[32m\"apple\"[39m | ||
But it threw: | ||
[31m\"Error: apple\"[39m" | ||
`; |
24 changes: 24 additions & 0 deletions
24
packages/jest-matchers/src/__tests__/_matchErrorSnapshot.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,24 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails oncall+jsinfra | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = fn => { | ||
let error; | ||
|
||
try { | ||
fn(); | ||
} catch (e) { | ||
error = e; | ||
} | ||
|
||
expect(error).toBeDefined(); | ||
expect(error.message).toMatchSnapshot(); | ||
}; |
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
Oops, something went wrong.