Has anyone been successful in using Vitest? We are having extremely weird issues that I think are due to import or export problems, but I'm not sure what.
Our entire test suite runs in Jest without issues. On Vitest, around 80% of our tests run successfully, including some GraphQL tests.
We have a test for a class called SignUpUseCase, but when I run this test it fails like so:
FAIL test/use-cases/SignUpUseCase.test.ts > SignUpUseCase > handle > should throw when email is already registered
Error: Undefined type error. Make sure you are providing an explicit type for the "finishGather" (parameter at index [0]) of the "GatherResolver" class.
This mutation in GatherResolver is apparently the culprit, but it looks just like any other in this file. I commented out all other mutations in this file, so this is the only one active:
@Mutation(() => FinishGatherOutput)
async finishGather(
@Args('input') input: FinishGatherInput,
): Promise<FinishGatherOutput> {
...
}
This FinishGatherInput is defined in a file finish-gather.ts, and is just these 2 simple classes, not much else, it doesn't even import other InputTypes or ObjectTypes from other files.
import { Field, InputType, ObjectType } from '@nestjs/graphql';
import { IsNotEmpty, IsUUID } from 'class-validator';
@InputType()
export class FinishGatherInput {
...
}
@ObjectType()
export class FinishGatherOutput {
...
}
The definitions from this file are exported in the index.ts on the same folder:
export * from ... [a bazillion of these]
export * from './finish-gather';
export * from ... [more bazillions of them]
But here's the thing: if I move the finish-gather export to the top of the file, the SignUpUseCase test runs fine, no graphql issues.... but then if I start uncommenting other mutations, then eventually I find some that fail, where this trick above doesn't work.
Can someone help?