-
Notifications
You must be signed in to change notification settings - Fork 49
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
Rule proposal: Forbid afterEach etc callback with serial #166
Comments
It does have a purpose though: // This would run first
test.serial.beforeEach(fn);
// Then these would run concurrently
test.beforeEach(fn);
test.beforeEach(fn); |
No, hooks run in order of registration, and for serial tests they automatically run serially: import test from 'ava'
test.beforeEach(async () => {
console.log('1.1', new Date())
await new Promise(resolve => setTimeout(resolve, 1000))
console.log('1.2', new Date())
})
test.serial.beforeEach(() => {
console.log('2', new Date())
})
test.beforeEach(async () => {
console.log('3.1', new Date())
await new Promise(resolve => setTimeout(resolve, 1000))
console.log('3.2', new Date())
})
test.beforeEach(async () => {
console.log('4.1', new Date())
await new Promise(resolve => setTimeout(resolve, 1000))
console.log('4.2', new Date())
})
test.serial('5', t => console.log('5', new Date()))
test('6', t => console.log('6', new Date()))
test('7', t => console.log('7', new Date())) Gives (note the timestamps): $ "$(npm bin)"/ava --verbose test.js
1.1 2017-01-12T16:25:58.964Z
1.2 2017-01-12T16:25:59.970Z
2 2017-01-12T16:25:59.975Z
3.1 2017-01-12T16:25:59.976Z
3.2 2017-01-12T16:26:00.981Z
4.1 2017-01-12T16:26:00.982Z
4.2 2017-01-12T16:26:01.986Z
5 2017-01-12T16:26:01.986Z
✔ 5
1.1 2017-01-12T16:26:01.988Z
1.1 2017-01-12T16:26:01.989Z
1.2 2017-01-12T16:26:02.994Z
1.2 2017-01-12T16:26:02.994Z
2 2017-01-12T16:26:02.995Z
2 2017-01-12T16:26:02.995Z
3.1 2017-01-12T16:26:02.995Z
3.1 2017-01-12T16:26:02.995Z
3.2 2017-01-12T16:26:04.000Z
3.2 2017-01-12T16:26:04.000Z
4.1 2017-01-12T16:26:04.001Z
4.1 2017-01-12T16:26:04.001Z
4.2 2017-01-12T16:26:05.003Z
4.2 2017-01-12T16:26:05.003Z
6 2017-01-12T16:26:05.003Z
✔ 6
✔ 7
7 2017-01-12T16:26:05.004Z
3 tests passed [16:26:05] |
Oh, right. Then I think we should disallow that combination in AVA too, at runtime, with a user-friendly message. |
No need for a rule for something that gets an error thrown, right? |
@mightyiam There is. It's useful with an early error that can be caught in the editor even before running the tests. |
|
@novemberborn I just tried |
@novemberborn Should we close this issue in favor of #186? |
Yup. |
This implies the callback only applies to serial tests, which is not the case. If I'm not mistaken regular
test.afterEach
hooks still run serially when run after atest.serial()
test.See avajs/ava#1178.
Fail
Valid
The text was updated successfully, but these errors were encountered: