Skip to content

Commit af9e2a3

Browse files
committed
chore: 🔧 Configure Cypress pour les tests de composants
1 parent 4e54240 commit af9e2a3

File tree

7 files changed

+136
-3
lines changed

7 files changed

+136
-3
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,16 @@ module.exports = {
3131
jest: true,
3232
},
3333
},
34+
{
35+
files: [
36+
'**/src/**/*.e2e.{j,t}s?(x)',
37+
],
38+
env: {
39+
'cypress/globals': true,
40+
},
41+
extends: [
42+
'plugin:cypress/recommended',
43+
],
44+
},
3445
],
3546
}

cypress.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"testFiles": "cypress/specs/**.spec.js",
2+
"testFiles": "cypress/tests/**/*.e2e.js",
33
"pluginsFile": "cypress/plugins/index.js",
44
"component": {
55
"componentFolder": "src",
6-
"testFiles": "**.e2e.js*",
6+
"testFiles": "**/*.e2e.js*",
77
"viewportHeight": 500,
88
"viewportWidth": 700
99
}

cypress/support/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
// ***********************************************************
1515

1616
// Import commands.js using ES2015 syntax:
17-
import './commands'
17+
import './commands.js'
1818

1919
// Alternatively you can use CommonJS syntax:
2020
// require('./commands')
21+
import 'cypress-plugin-tab'

package-lock.json

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build:js": "cross-env NODE_ENV=production rollup --config rollup.config.js",
2222
"demo-app": "vite",
2323
"test": "jest",
24+
"test:ct": "cypress open-ct",
2425
"format": "npm run lint -- --fix",
2526
"lint": "eslint ./src/**/*.{vue,js,jsx,ts,tsx}",
2627
"storybook": "start-storybook -p 6006 -s public",
@@ -40,6 +41,7 @@
4041
"@babel/plugin-syntax-jsx": "^7.16.0",
4142
"@babel/preset-env": "^7.16.4",
4243
"@cypress/vite-dev-server": "^2.2.1",
44+
"@cypress/vue": "^3.0.5",
4345
"@rollup/plugin-alias": "^3.1.8",
4446
"@rollup/plugin-babel": "^5.3.0",
4547
"@rollup/plugin-commonjs": "^21.0.1",
@@ -70,6 +72,7 @@
7072
"core-js": "^3.19.1",
7173
"cross-env": "^7.0.3",
7274
"cypress": "^9.0.0",
75+
"cypress-plugin-tab": "^1.0.5",
7376
"eslint": "^7.32.0",
7477
"eslint-plugin-cypress": "^2.12.1",
7578
"eslint-plugin-import": "^2.25.3",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { mount } from '@cypress/vue'
2+
import DsfrButton from './DsfrButton'
3+
4+
describe('DsfrButton', () => {
5+
it('Simple Button', () => {
6+
mount(DsfrButton, {
7+
slots: {
8+
default: 'Test button',
9+
},
10+
})
11+
12+
cy.get('button').contains('Test button').click()
13+
})
14+
})

vite.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export default defineConfig({
2323
find: '@',
2424
replacement: path.resolve(projectDir, 'src'),
2525
},
26+
{
27+
find: 'vue',
28+
replacement: 'vue/dist/vue.esm-bundler.js',
29+
},
2630
],
2731
},
2832
build: {

0 commit comments

Comments
 (0)