-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
chained methods do not have correct ExtraContext #2892
Comments
I think it's caused by this line vitest/packages/runner/src/types/tasks.ts Line 148 in 482b72f
and it appears to be fixed by changing it to
But I'm not sure if that has other downsides. |
This issue appears to affect
Given that |
This could be some limitation on typescript's Instead of https://stackblitz.com/edit/vitest-dev-vitest-mvn39n?file=test%2Fcontext.test.ts import { it } from 'vitest';
import type { CustomAPI } from '@vitest/runner';
// const cit = it<{ now: Date }>;
const cit = it as CustomAPI<{ now: Date }>;
cit('', ({ now }) => {
now satisfies Date;
});
cit.skip('', ({ now }) => {
now satisfies Date;
}); |
Now that import { it, type TestAPI } from 'vitest';
const cit = it as TestAPI<{ now: Date }>; |
Describe the bug
Chaining methods reset ExtraContext to
{}
.it<Context>.skip
will use{}
instead ofContext
. Whileit.skip<Context>
will work it's not as ergonomic asit<Context>.skip
especially when assigning a context'ed it to a variable for reuse.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-pwreuv?file=test/context.test.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: