You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 add import.meta.env.MODE = 'test' in the vitest.setup.ts to reset mode.
Then, most of the test run well, but when I test pinia action calling, I got TypeError: [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 with vi.fn or pinia/testing for Promise 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, while vitest in the reproduction.
When I add --mode development in the reproduction, it also throw TypeError: [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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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.
Beta Was this translation helpful? Give feedback.
All reactions