do not set development mode when running vitest #2049
Unanswered
Fallsleep
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For convenience, I want to reuse the
.env.development.local
instead creating a specific.env.test
.For this, I change the test script to
vitest --mode development
and addimport.meta.env.MODE = 'test'
in thevitest.setup.ts
to reset mode.Then, most of the test run well, but when I test
pinia
action calling, I gotTypeError: [Function] is not a spy or a call to a spy!
like reproduction.As I returned a
Promise
in the action, I think there's someting wrong withvi.fn
orpinia/testing
forPromise
at first.In order to find the reason, I add an example on
stackblitz
for reproduction, but the test running no error!After a lot of try, include upgrade
vite/vitest/pinia/happy-dom
and get many other error, I found out the test script is deffirent in my project and the reproduction.I use
vitest --mode development
in my project, whilevitest
in the reproduction.When I add
--mode development
in the reproduction, it also throwTypeError: [Function] is not a spy or a call to a spy!
So, don't set development mode when running vitest, it may course unkown error.
I also add a discussion in vitest-dev/vitest#2955
Beta Was this translation helpful? Give feedback.
All reactions