-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test.todo #6996
Merged
Merged
Add test.todo #6996
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fdd340b
Add test.todo to jest-jasmine
mattphillips 3cbe1c0
Add test.todo to jest-circus
mattphillips 392c1d0
Add end to end tests
mattphillips ec08b6f
Remove unused interface
mattphillips 663ed55
Group todo tests into one log per suite
mattphillips a720cde
Remove stringifying of invalid arg
mattphillips 1a17252
Add capture stack trace to invalid args error
mattphillips 54fac6d
Add changelog entry
mattphillips 8891c36
Remove unnessecary snapshot normalisation
mattphillips 0e3fb84
Add docs
mattphillips 7325d16
Add use test.todo suggestion to tests without callback function
mattphillips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`shows error messages when called with invalid argument 1`] = ` | ||
"FAIL __tests__/todo_non_string.test.js | ||
● Test suite failed to run | ||
|
||
Todo must be called with only a description. | ||
|
||
6 | */ | ||
7 | | ||
> 8 | it.todo(() => {}); | ||
| ^ | ||
9 | | ||
|
||
at __tests__/todo_non_string.test.js:8:4 | ||
|
||
" | ||
`; | ||
|
||
exports[`shows error messages when called with multiple arguments 1`] = ` | ||
"FAIL __tests__/todo_multiple_args.test.js | ||
● Test suite failed to run | ||
|
||
Todo must be called with only a description. | ||
|
||
6 | */ | ||
7 | | ||
> 8 | it.todo('todo later', () => {}); | ||
| ^ | ||
9 | | ||
|
||
at __tests__/todo_multiple_args.test.js:8:4 | ||
|
||
" | ||
`; | ||
|
||
exports[`shows error messages when called with no arguments 1`] = ` | ||
"FAIL __tests__/todo_no_args.test.js | ||
● Test suite failed to run | ||
|
||
Todo must be called with only a description. | ||
|
||
6 | */ | ||
7 | | ||
> 8 | it.todo(); | ||
| ^ | ||
9 | | ||
|
||
at __tests__/todo_no_args.test.js:8:4 | ||
|
||
" | ||
`; | ||
|
||
exports[`works with all statuses 1`] = ` | ||
"FAIL __tests__/statuses.test.js | ||
✓ passes | ||
✕ fails | ||
○ skipped 1 test | ||
✎ todo 1 test | ||
|
||
● fails | ||
|
||
expect(received).toBe(expected) // Object.is equality | ||
|
||
Expected: 101 | ||
Received: 10 | ||
|
||
11 | | ||
12 | it('fails', () => { | ||
> 13 | expect(10).toBe(101); | ||
| ^ | ||
14 | }); | ||
15 | | ||
16 | it.skip('skips', () => { | ||
|
||
at __tests__/statuses.test.js:13:14 | ||
|
||
" | ||
`; |
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,43 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. 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. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
const {extractSummary} = require('../Utils'); | ||
const dir = path.resolve(__dirname, '../test-todo'); | ||
|
||
test('works with all statuses', () => { | ||
const result = runJest(dir, ['statuses.test.js']); | ||
expect(result.status).toBe(1); | ||
const {rest} = extractSummary(result.stderr); | ||
expect(rest).toMatchSnapshot(); | ||
}); | ||
|
||
test('shows error messages when called with no arguments', () => { | ||
const result = runJest(dir, ['todo_no_args.test.js']); | ||
expect(result.status).toBe(1); | ||
const {rest} = extractSummary(result.stderr); | ||
expect(rest).toMatchSnapshot(); | ||
}); | ||
|
||
test('shows error messages when called with multiple arguments', () => { | ||
const result = runJest(dir, ['todo_multiple_args.test.js']); | ||
expect(result.status).toBe(1); | ||
const {rest} = extractSummary(result.stderr); | ||
expect(rest).toMatchSnapshot(); | ||
}); | ||
|
||
test('shows error messages when called with invalid argument', () => { | ||
const result = runJest(dir, ['todo_non_string.test.js']); | ||
expect(result.status).toBe(1); | ||
const {rest} = extractSummary(result.stderr); | ||
expect(rest).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,20 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. 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. | ||
*/ | ||
|
||
it('passes', () => { | ||
expect(10).toBe(10); | ||
}); | ||
|
||
it('fails', () => { | ||
expect(10).toBe(101); | ||
}); | ||
|
||
it.skip('skips', () => { | ||
expect(10).toBe(101); | ||
}); | ||
|
||
it.todo('todo'); |
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,8 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. 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. | ||
*/ | ||
|
||
it.todo('todo later', () => {}); |
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,8 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. 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. | ||
*/ | ||
|
||
it.todo(); |
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,8 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. 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. | ||
*/ | ||
|
||
it.todo(() => {}); |
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
42 changes: 42 additions & 0 deletions
42
packages/jest-circus/src/__tests__/circus_todo_test_error.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,42 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. 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. | ||
* | ||
* @flow strict-local | ||
*/ | ||
|
||
'use strict'; | ||
|
||
let circusIt; | ||
|
||
// using jest-jasmine2's 'it' to test jest-circus's 'it'. Had to differentiate | ||
// the two with this alias. | ||
|
||
const aliasCircusIt = () => { | ||
const {it} = require('../index.js'); | ||
circusIt = it; | ||
}; | ||
|
||
aliasCircusIt(); | ||
|
||
describe('test/it.todo error throwing', () => { | ||
it('todo throws error when given no arguments', () => { | ||
expect(() => { | ||
// $FlowFixMe: Testing runitme errors here | ||
circusIt.todo(); | ||
}).toThrowError('Todo must be called with only a description.'); | ||
}); | ||
it('todo throws error when given more than one argument', () => { | ||
expect(() => { | ||
circusIt.todo('test1', () => {}); | ||
}).toThrowError('Todo must be called with only a description.'); | ||
}); | ||
it('todo throws error when given none string description', () => { | ||
expect(() => { | ||
// $FlowFixMe: Testing runitme errors here | ||
circusIt.todo(() => {}); | ||
}).toThrowError('Todo must be called with only a description.'); | ||
}); | ||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check how this looks on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimenB I don't have a windows machine, does anyone else have one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://modern.ie