Skip to content

Commit 88dfd81

Browse files
committed
Upgrade cypress to version 11.2.0 to work with vite
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
1 parent ba6f5a1 commit 88dfd81

8 files changed

Lines changed: 60 additions & 51 deletions

File tree

cypress.config.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { defineConfig } from 'cypress'
2+
import plugins from './cypress/plugins/index.mjs'
3+
import viteConfig from './vite.config.mjs'
4+
5+
export default defineConfig({
6+
projectId: '3paxvy',
7+
viewportWidth: 1920,
8+
viewportHeight: 1080,
9+
defaultCommandTimeout: 6000,
10+
11+
env: viteConfig.test.env,
12+
13+
screenshotsFolder: 'cypress/snapshots/actual',
14+
trashAssetsBeforeRuns: true,
15+
16+
component: {
17+
devServer: {
18+
framework: 'vue',
19+
bundler: 'vite',
20+
viteConfig,
21+
},
22+
specPattern: 'tests/visual/**/*.visual.*',
23+
setupNodeEvents(on, config) {
24+
return plugins(on, config)
25+
},
26+
},
27+
})

cypress.json

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,10 @@
88
// https://on.cypress.io/plugins-guide
99
// ***********************************************************
1010

11-
// This function is called when a project is opened or re-opened (e.g. due to
12-
// the project's config changing)
13-
14-
const getCompareSnapshotsPlugin = require('cypress-visual-regression/dist/plugin')
15-
16-
const webpack = require('@cypress/webpack-preprocessor')
17-
const { startDevServer } = require('@cypress/webpack-dev-server')
18-
19-
module.exports = async (on, config) => {
20-
const webpackOptions = await require('../../webpack.config.js')()
21-
webpackOptions.externals = {}
22-
23-
const options = {
24-
// send in the options from your webpack.config.js, so it works the same
25-
// as your app's code
26-
webpackOptions,
27-
watchOptions: {},
28-
}
11+
import getCompareSnapshotsPlugin from 'cypress-visual-regression/dist/plugin.js'
2912

13+
export default async (on, config) => {
3014
getCompareSnapshotsPlugin(on, config)
31-
on('file:preprocessor', webpack(options))
32-
33-
on('dev-server:start', (options) => {
34-
return startDevServer({ options, webpackConfig: webpackOptions })
35-
})
3615

3716
// Disable spell checking to prevent rendering differences
3817
on('before:browser:launch', (browser, launchOptions) => {

cypress/support/commands.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Components App</title>
8+
<div id="__next_css__DO_NOT_USE__"></div>
9+
</head>
10+
<body>
11+
<div data-cy-root></div>
12+
</body>
13+
</html>
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/component.js is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and
@@ -13,4 +13,16 @@
1313
// https://on.cypress.io/configuration
1414
// ***********************************************************
1515

16-
import './commands'
16+
import { mount } from 'cypress/vue2'
17+
import compareSnapshotCommand from 'cypress-visual-regression/dist/command.js'
18+
19+
compareSnapshotCommand()
20+
21+
const Cypress = window.Cypress
22+
23+
Cypress.Commands.add('mount', mount)
24+
25+
if (global.process === undefined) global.process = {}
26+
global.process.env = {
27+
...Cypress.env(),
28+
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@
9595
"@vue/test-utils": "^1.3.3",
9696
"browserslist-to-esbuild": "^1.2.0",
9797
"concurrently": "^7.6.0",
98-
"cypress": "^9.7.0",
99-
"cypress-visual-regression": "^1.5.0",
100-
"eslint-plugin-cypress": "^2.11.1",
98+
"cypress": "^11.2.0",
99+
"cypress-visual-regression": "^1.7.0",
100+
"eslint-plugin-cypress": "^2.12.1",
101101
"gettext-extractor": "^3.6.0",
102102
"gettext-parser": "^6.0.0",
103103
"jsdom": "^20.0.3",

tests/visual/components/NcAppSidebar/NcAppSidebarMixin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*
2121
*/
2222

23-
import { mount } from '@cypress/vue'
2423
import sanitize from 'sanitize-filename'
2524

2625
import NcAppSidebar from '../../../../src/components/NcAppSidebar/NcAppSidebar.vue'
@@ -96,7 +95,7 @@ export default function(compact) {
9695
}
9796

9897
it('Renders ' + fileName, () => {
99-
mount(NcAppSidebar, defaultOptions)
98+
cy.mount(NcAppSidebar, defaultOptions)
10099
cy.get('.app-sidebar-header').compareSnapshot(fileName)
101100
})
102101
})

0 commit comments

Comments
 (0)