Closed jacksongross closed 1 year ago
Hmm, appears uninstalling/reinstalling @quasar/quasar-app-extension-testing-unit-vitest
has fixed it for me. Sorry about that, really thought I tried this!
Turns out this is happening in other cases as well. Test fails without installQuasar
on
❯ ReactiveEffect.fn ../../node_modules/quasar/src/composables/private/use-dark.js:14:12
TypeError: Cannot read properties of undefined (reading 'dark')
12| return computed(() => (
13| props.dark === null
14| ? $q.dark.isActive
| ^
15| : props.dark
16| ))
but get the same Error: Snapshot cannot be used outside of test
when calling that helper.
So it appears this error happens if there's an uncaught error somewhere in test setup -- in my case I had a module manual mock I was running before my tests which seems to be causing my issue. I will close this as the issue clearly isn't this plugin. Sorry for the spam!
That's a confusing error message indeed, thanks for investigating and providing the solution 👍🏻
Software version
OS: macOS 12.2.1 Node: 16.17.0 NPM: 8.15.0 Any other software related to your bug:
What did you get as the error?
For a very basic component: Splashscreen.vue
running the simple test below: Splashscreen.spec.js
I got the following error:
But if I remove the
installQuasar
import and function call before the tests, it passes.Funnily enough, I have to also remove the import for it to work; just commenting out
installQuasar()
doesn't fix it.What were you expecting?
The test to pass and snapshots to be written/compared by vitest.
What steps did you take, to get the error?
See above reproduction example