mammadataei / cypress-vite

Run Cypress specs using Vite
MIT License
85 stars 10 forks source link

cypress-vite with typescript error #90

Closed ethonai-dino closed 7 months ago

ethonai-dino commented 7 months ago

TypeError: (0 , cypress_vite_1.default) is not a function

{
  "devDependencies": {
    "cypress": "13.6.3",
    "cypress-vite": "1.5.0",
    "typescript": "5.3.3"
  }
}
Screenshot 2024-01-25 at 18 14 32

Stacktrace

TypeError: (0 , cypress_vite_1.default) is not a function
    at setupNodeEvents (/Users/user/Projects/cypress-vite-test/cypress.config.ts:19:53)
    at /Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14
    at tryCatcher (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)
    at RunPlugins.load (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)
    at RunPlugins.runSetupNodeEvents (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)
    at EventEmitter. (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)
    at EventEmitter.emit (node:events:517:28)
    at EventEmitter.emit (node:domain:489:12)
    at process. (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:517:28)
    at process.emit (node:domain:489:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/user/Library/Caches/Cypress/13.6.3/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:944:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
matthiasmoke commented 7 months ago

Same here. My cypress and cypress-vite versions are equal. My general vite version is 5.0.10. I thought maybe downgrading to 4.5 fixes the issue, as Cypress shows compatibility warnings with version 5, but unfortunately it didn't :(

ethonai-dino commented 7 months ago

@matthiasmoke

Made it work by changing my cypress.config.ts to JS (cypress.config.js)

const { defineConfig } = require('cypress')
const vitePreprocessor = require("cypress-vite");

module.exports = defineConfig({
    e2e: {
        setupNodeEvents(on) {
            on('file:preprocessor', vitePreprocessor())
        }
    },
});

🤷

mammadataei commented 7 months ago

Duplicate of #13. @ethonai-dino I think this should help and you don't need to change your config to js.