-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polish failure reporting in Jest. (#1458)
- Loading branch information
Showing
26 changed files
with
317 additions
and
227 deletions.
There are no files selected for viewing
26 changes: 15 additions & 11 deletions
26
integration_tests/__tests__/__snapshots__/console-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
9 changes: 9 additions & 0 deletions
9
integration_tests/__tests__/__snapshots__/failures-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,9 @@ | ||
exports[`test failure messages 1`] = ` | ||
" console.log __tests__/test-error-test.js:12 | ||
This is what a log looks like. | ||
console.error __tests__/test-error-test.js:14 | ||
This is what an error looks like. | ||
" | ||
`; |
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,18 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
|
||
it('failure messages', () => { | ||
const dir = path.resolve(__dirname, '../failures'); | ||
const {stdout} = runJest(dir); | ||
expect(stdout).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
6 changes: 6 additions & 0 deletions
6
integration_tests/failures/__tests__/__snapshots__/test-error-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,6 @@ | ||
exports[`failure messages toMatchSnapshot 1`] = ` | ||
Object { | ||
"a": 1, | ||
"b": 2 | ||
} | ||
`; |
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,69 @@ | ||
/** | ||
* 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. | ||
*/ | ||
'use strict'; | ||
|
||
describe('failure messages', () => { | ||
test('logs', () => { | ||
console.log('This is what a log looks like.'); | ||
|
||
console.error('This is what an error looks like.'); | ||
}); | ||
|
||
[ | ||
() => expect(1).toBe(2), | ||
() => expect('a').toBe(2), | ||
() => expect(true).toBe(5), | ||
() => expect({a: 1, b: 2}).toBe({a: 1, b: 3}), | ||
() => expect({ | ||
a: 1, | ||
b: 2, | ||
c: { | ||
apple: 'banana', | ||
}, | ||
}).toEqual({ | ||
a: 2, | ||
b: 2, | ||
c: { | ||
kiwi: 'melon', | ||
}, | ||
}), | ||
() => expect([1, 2, 3]).toEqual([2, 3, 1]), | ||
() => expect([1, 2, 3]).toEqual([1, 3, 2]), | ||
() => expect(true).not.toBeTruthy(), | ||
() => expect(false).toBeTruthy(), | ||
() => expect(true).toBeFalsy(), | ||
() => expect(false).not.toBeFalsy(), | ||
() => expect({a: 1, b: 2}).toBeFalsy(), | ||
() => expect(1).toBeNaN(), | ||
() => expect({}).toBeNull(), | ||
() => expect(undefined).toBeDefined(), | ||
() => expect(1).toBeUndefined(), | ||
() => expect(1).toBeGreaterThan(5), | ||
() => expect(1).toBeGreaterThanOrEqual(5), | ||
() => expect(5).toBeLessThan(1), | ||
() => expect(5).toBeLessThanOrEqual(1), | ||
() => expect([1, 2]).toContain({apple: 'banana'}), | ||
() => expect(4).toBeCloseTo(100), | ||
() => expect('hello this is a message').toMatch('bye'), | ||
() => expect(() => {}).toThrow(), | ||
() => expect(() => {}).toThrow(new TypeError('This is an error!')), | ||
() => expect(() => { throw new Error('not an error'); }) | ||
.toThrow('This is an error!'), | ||
() => expect(() => {}).toThrow('This is an error!'), | ||
() => expect(() => { throw new Error('not an error'); }) | ||
.toThrowError('This is an error!'), | ||
].forEach(fn => test(fn.toString(), fn)); | ||
|
||
test('toMatchSnapshot', () => { | ||
expect({ | ||
a: 1, | ||
apple: 'banana', | ||
}).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
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
Oops, something went wrong.