Cypress component testing does not work with composables VueUse - "ref is not defined"

Viewed 870

For some reason VueUse is breaking my tests in Cypress component testing. No matter what composable I use, it will throw errors > ref is not defined or > watch is not defined. I checked sources and notice that vueuse uses vue-demi under hood, and all problems are related with imports from vue-demi. But I tried to import something from vue-demi alone, and it works, so I'm confused why it crashes with vueuse.

My setup Vue 3 + Vite. Reproduction: https://github.com/chojnicki/vitesse Vitesse starter template already has Vue3/Vite and VueUse, so I just added Cypress and same error appears after running yarn cypress run-ct

I tired to make this live on codesandbox, but Cypress does not work there due to missing system libraries.

Is this a bug or I'm missing something here?

Log:

 at Object.ref (http://localhost:35783/__cypress/src/node_modules/.vite/@vueuse_core.js?v=9e0ceea7:94:17)
    at useMediaQuery (http://localhost:35783/__cypress/src/node_modules/.vite/@vueuse_core.js?v=9e0ceea7:1152:41)
    at usePreferredDark (http://localhost:35783/__cypress/src/node_modules/.vite/@vueuse_core.js?v=9e0ceea7:1379:11)
    at useDark (http://localhost:35783/__cypress/src/node_modules/.vite/@vueuse_core.js?v=9e0ceea7:1383:26)
    at <unknown> (http://localhost:35783/__cypress/src/src/logic/dark.ts:2:24)
From previous event:
    at Object.runScripts (http://localhost:35783/__cypress/runner/cypress_runner.js:159792:22)
    at $Cypress.onSpecWindow (http://localhost:35783/__cypress/runner/cypress_runner.js:149271:19)
    at <unknown> (http://localhost:35783/__cypress/src/@fs//home/chojnicki/vitesse/node_modules/@cypress/vite-dev-server/client/initCypressTests.js:22:18)
1 Answers
Related