Open meza opened 1 year ago
It was a breaking change. To extend context, you need to augment @vitest/runner
module now. Documentation should be updated
Do you have an example of this somewhere? Just trying to have simple, local test contexts.
I am facing similar issue.
To fix my issue, I had to make following changes
TestContext
declaration so that instead of module vitest
, module @vitest/runner
is augmented.TestContext
and it
from vitest
to @vitest/runner
it
blocks with TestContext
. @sheremet-va This one was quiet tedious. This was not required earlier. Here's change in code
- declare module "vitest" {
+ declare module "@vitest/runner" {
export interface TestContext {
app: App
}
}
- import { beforeEach, describe, expect, it, TestContext } from "vitest";
+ import { beforeEach, describe, expect } from "vitest";
+ import { it, TestContext } from "@vitest/runner";
...
- it("should initialize screening state with empty object", function({ app }) {
+ it<TestContext>("test description", function({ app, expect }) {
Because of point no. 3 I have put upgrade to 0.28.2
on hold. Would like to wait for the official clarification on this issue.
Would like to wait for the official clarification on this issue.
Points 2 and 3 are bugs. Point 1 is expected.
Feels like a big step backwards in usability if this augmentation has to be done even for local test contexts
Feels like a big step backwards in usability if this augmentation has to be done even for local test contexts
Yes, it is a bug. You shouldn't need to augment global context to use local contexts.
Thanks for the clarification, that sounds much better :)
@sheremet-va might this also cause type tests to not work correctly? Eg. this test is passing even though it clearly shouldn't pass (and the IDE also shows the types not matching)
test('type', () => {
expectTypeOf(5).toEqualTypeOf<string>();
});
@sheremet-va might this also cause type tests to not work correctly? Eg. this test is passing even though it clearly shouldn't pass (and the IDE also shows the types not matching)
I don't think it's related. Please, open a separate issue.
For some reason, reexporting types in pnpm doesn't work. Typescript doesn't pick up types from @vitest/runner
and all test
/describe
/... functions are marked as any.
When using other package managers local context types work fine.
I found it! It's the "preserveSymlinks": true
in the tsconfig!
@sheremet-va might this also cause type tests to not work correctly? Eg. this test is passing even though it clearly shouldn't pass (and the IDE also shows the types not matching)
test('type', () => { expectTypeOf(5).toEqualTypeOf<string>(); });
Is there any news on this? In version 1.0.0-beta.5
as well as in the versions below, the tests are still passed. This makes expectTypeOf
currently unusable.
@sheremet-va might this also cause type tests to not work correctly? Eg. this test is passing even though it clearly shouldn't pass (and the IDE also shows the types not matching)
test('type', () => { expectTypeOf(5).toEqualTypeOf<string>(); });
Is there any news on this? In version
1.0.0-beta.5
as well as in the versions below, the tests are still passed. This makesexpectTypeOf
currently unusable.
This issue is not even about TypeScript typechecker. If you have any problems, open a new issue with a reproduction.
Describe the bug
Since v0.28.1, typescript now considers all test context variables to be implicit any types.
Reproduction
The error popped up in this automated dependency PR: https://github.com/meza/minecraft-mod-manager/pull/208
You can reproduce it in the branch it refers to.
System Info
Used Package Manager
pnpm
Validations