mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-07 15:31:30 -05:00
fix: do not register CT specific event in e2e mode
This commit is contained in:
+6
-2
@@ -1339,8 +1339,12 @@ jobs:
|
||||
name: Build
|
||||
command: yarn workspace @cypress/vue build
|
||||
- run:
|
||||
name: Run tests
|
||||
command: yarn test-ci
|
||||
name: Run component tests
|
||||
command: yarn test-ci:ct
|
||||
working_directory: npm/vue
|
||||
- run:
|
||||
name: Run e2e tests
|
||||
command: yarn test:ci:e2e
|
||||
working_directory: npm/vue
|
||||
- store_test_results:
|
||||
path: npm/vue/test_results
|
||||
|
||||
@@ -7,7 +7,7 @@ const webpackConfig = require('../../webpack.config')
|
||||
*/
|
||||
module.exports = (on, config) => {
|
||||
if (config.testingType !== 'component') {
|
||||
throw Error(`This is a component testing project. testingType should be 'component'. Received ${config.testingType}`)
|
||||
return config
|
||||
}
|
||||
|
||||
if (!webpackConfig.resolve) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference types="cypress" />
|
||||
import { mount } from '@cypress/vue'
|
||||
|
||||
Cypress.Commands.add('mount', (comp) => {
|
||||
return mount(comp)
|
||||
})
|
||||
@@ -1 +1,3 @@
|
||||
// created automatically when cy:open starts
|
||||
|
||||
import './commands'
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"build-prod": "yarn build",
|
||||
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
|
||||
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
|
||||
"cy:run:e2e": "node ../../scripts/cypress.js run --project ${PWD}",
|
||||
"test": "yarn cy:run",
|
||||
"watch": "yarn build --watch --watch.exclude ./dist/**/*",
|
||||
"test-ci": "node ../../scripts/run-ct-examples.js --examplesList=./examples.env"
|
||||
|
||||
@@ -36,6 +36,16 @@ type CyMountOptions<Props> = Omit<MountingOptions<Props>, 'attachTo'> & {
|
||||
let initialInnerHtml = ''
|
||||
|
||||
Cypress.on('run:start', () => {
|
||||
// `mount` is designed to work with component testing only.
|
||||
// it assumes ROOT_ID exists, which is not the case in e2e.
|
||||
// if the user registers a custom command that imports `cypress/vue`,
|
||||
// this event will be registered and cause an error when the user
|
||||
// launches e2e (since it's common to use Cypress for both CT and E2E.
|
||||
// https://github.com/cypress-io/cypress/issues/17438
|
||||
if (Cypress.testingType !== 'component') {
|
||||
return
|
||||
}
|
||||
|
||||
initialInnerHtml = document.head.innerHTML
|
||||
Cypress.on('test:before:run', () => {
|
||||
Cypress.vueWrapper?.unmount()
|
||||
|
||||
Reference in New Issue
Block a user