-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Detect t.try() usage in hooks; experimentally disable t.snapshot() #2527
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
Merged
novemberborn
merged 12 commits into
avajs:master
from
oantoro:disable-snapshot-and-try-in-hooks
Jul 4, 2020
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9b759f3
Disable snapshots and try assertions in hooks
oantoro 63f85df
Make disable snapshots in hooks as experimental
oantoro 63568bf
Move hooks test to self-host test
oantoro ec30362
Fix test title name
oantoro f21e1ce
Merge branch 'master' into disable-snapshot-and-try-in-hooks
novemberborn 40528db
Adjust error copy
novemberborn 382fb62
Keep experiments in alphabetic order (sorry)
novemberborn 9a8781d
Throw for t.try() earlier
novemberborn 2fe0c93
Remove hook helper for TAP tests
novemberborn 8671441
Move hook-failed case up
novemberborn 1da60d3
Improve tests
novemberborn 4da6c18
Merge branch 'master' into disable-snapshot-and-try-in-hooks
novemberborn 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
test/hook-restrictions/fixtures/invalid-snapshots-in-hooks.js
This file contains hidden or 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 @@ | ||
const test = require('ava'); | ||
|
||
test.before(t => { | ||
t.snapshot({}); | ||
}); | ||
|
||
test('cannot use snapshot in hook', t => { | ||
t.pass(); | ||
}); |
This file contains hidden or 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 @@ | ||
const test = require('ava'); | ||
|
||
test.before(async t => { | ||
await t.try(tt => tt.pass()); | ||
}); | ||
|
||
test('cannot use `t.try()` in hook', t => { | ||
t.pass(); | ||
}); |
This file contains hidden or 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,10 @@ | ||
{ | ||
"ava": { | ||
"files": [ | ||
"*.js" | ||
], | ||
"nonSemVerExperiments": { | ||
"disableSnapshotsInHooks": true | ||
} | ||
} | ||
} |
This file contains hidden or 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,17 @@ | ||
# Snapshot report for `test/hook-restrictions/test.js` | ||
|
||
The actual snapshot is saved in `test.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## `t.try()` cannot be used in hooks | ||
|
||
> error message | ||
|
||
'`t.try()` can only be used in tests' | ||
|
||
## snapshots cannot be used in hooks | ||
|
||
> error message | ||
|
||
'`t.snapshot()` can only be used in tests' |
Binary file not shown.
This file contains hidden or 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,14 @@ | ||
const test = require('@ava/test'); | ||
const exec = require('../helpers/exec'); | ||
|
||
test('snapshots cannot be used in hooks', async t => { | ||
const result = await t.throwsAsync(exec.fixture('invalid-snapshots-in-hooks.js')); | ||
const error = result.stats.getError(result.stats.failedHooks[0]); | ||
t.snapshot(error.message, 'error message'); | ||
}); | ||
|
||
test('`t.try()` cannot be used in hooks', async t => { | ||
const result = await t.throwsAsync(exec.fixture('invalid-t-try-in-hooks.js')); | ||
const error = result.stats.getError(result.stats.failedHooks[0]); | ||
t.snapshot(error.message, 'error message'); | ||
}); |
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.
Uh oh!
There was an error while loading. Please reload this page.