We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider code: test1.spec.ts
test1.spec.ts
import { test as originalTest } from 'vitest'; type Fixture = { foo: number }; const test = originalTest.extend<Fixture>({ foo: async ({}, use) => { await use(1); }, }); beforeEach<Fixture>(({ foo })=> { console.log(`beforeEach ${foo}`); }); afterEach<Fixture>(({ foo }) => { console.log(`afterEach ${foo}`); });
In this case we'll get not data in beforeEach as expected, but afterEach can access the data.
beforeEach undefined afterEach 1
Consider pretty similar case test2.spec.ts
test2.spec.ts
import { test as originalTest } from 'vitest'; type Fixture = { foo: number }; const test = originalTest.extend<Fixture>({ foo: async ({}, use) => { await use(1); }, }); beforeEach<Fixture>(({ foo })=> { console.log(`beforeEach ${foo}`); return ({ foo: afterFoo }) => { console.log(`afterEach ${foo} / ${afterFoo}`); }; });
This code will throw on beforeEach callback (effectively an analogue to afterEach), I would expect to actually see:
beforeEach
afterEach
beforeEach undefined afterEach undefined / 1
See above
Not applicable
yarn
The text was updated successfully, but these errors were encountered:
This looks like a bug, but I would expect it to work like test.beforeEach because you can define separate contexts at the top level
test.beforeEach
Sorry, something went wrong.
test.extend
Successfully merging a pull request may close this issue.
Describe the bug
Consider code:
test1.spec.ts
In this case we'll get not data in beforeEach as expected, but afterEach can access the data.
Consider pretty similar case
test2.spec.ts
This code will throw on
beforeEach
callback (effectively an analogue toafterEach
), I would expect to actually see:Reproduction
See above
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: