-
-
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
toBeInstanceOf does not properly recognise instance when using baseUrl in tsconfig #2686
Comments
Vitest doesn't recognise tsconfig. If you want to rely on it, install vite-tsconfig-paths plugin. Your particular case incorrectly resolves url, but still loads a module, because it's relative to |
This syntax is not supported without vite-tsconfig-paths. The fact that it "works" sometimes is a coincidence. When resolving paths, Vite thinks that |
Describe the bug
Hello All,
I've noticed unexpected behaviour that I believe is a bug. I've replicated it on Stackblitz, you can check it here: https://stackblitz.com/edit/node-qasnfa
As you can see, the tests fail on
toBeInstanceOf
check.The tested function is very simple, it just creates an instance of the
User
classNow, this test fails, even though it should not:
It fails, because
create.ts
file is importinguser.ts
"directly"./user.ts
, while the test suite is referrng to it in relation totsconfig
baseUrl
setting.If I change the import statement in the test suite...
It works perfectly
Reproduction
https://stackblitz.com/edit/node-qasnfa
Just run
npm run test
System Info
This is from Stacblitz but the same issue occurs on my MacOS System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 16.14.2 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 7.17.0 - /usr/local/bin/npm npmPackages: vitest: ^0.27.1 => 0.27.1
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: