-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcypress.config.js
More file actions
109 lines (101 loc) · 3.11 KB
/
Copy pathcypress.config.js
File metadata and controls
109 lines (101 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { defineConfig } from 'cypress';
import fs from 'fs';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
import registerCodeCoverageTasks from '@cypress/code-coverage/task.js';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', {
readFileMaybe(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename,
'utf8');
}
return null;
},
moveFile({ from, to }) {
fs.renameSync(from, to);
return null;
},
});
if (process.env.VITE_COVERAGE) {
try {
console.log('Loading code coverage task for e2e');
registerCodeCoverageTasks(on, config);
} catch (error) {
console.warn('Could not load code coverage task:', error.message);
}
}
// Filter specs by test group if specified
if (process.env.CYPRESS_TEST_GROUP) {
config.specPattern = `cypress/e2e/group-${process.env.CYPRESS_TEST_GROUP}/**/*.cy.{js,jsx}`;
}
return config;
},
baseUrl: 'http://localhost:3000',
numTestsKeptInMemory: 2
},
component: {
specPattern: ['packages/**/*.cy.{js,jsx}', 'apps/**/*.cy.{js,jsx}'],
devServer: {
framework: 'react',
bundler: 'vite',
viteConfig: async () => {
const istanbul = (await import('vite-plugin-istanbul')).default;
return {
mode: 'test',
resolve: {
alias: {
'@opencloning/ui': resolve(__dirname, 'packages/ui/src'),
'@opencloning/store': resolve(__dirname, 'packages/store/src'),
'@opencloning/utils': resolve(__dirname, 'packages/utils/src/utils'),
'@opencloning/opencloning-elabftw': resolve(__dirname, 'packages/opencloning-elabftw/src'),
},
},
plugins: [
(process.env.VITE_COVERAGE) && istanbul({
include: [
'packages/*/src/*',
'apps/*/src/*'
],
extension: ['.js', '.jsx'],
}),
ViteEjsPlugin({
umami_website_id: process.env.VITE_UMAMI_WEBSITE_ID,
}),
react(),
],
optimizeDeps: {
include: [
'@emotion/react',
'@emotion/styled',
'@mui/material/Tooltip',
'@mui/material/Unstable_Grid2'
],
entries: ['packages/**/*.cy.{js,jsx}', 'apps/**/*.cy.{js,jsx}', 'cypress/**/*.js'],
exclude: ['fsevents'],
},
ssr: {
noExternal: ['fsevents'],
},
};
},
},
setupNodeEvents(on, config) {
if (process.env.VITE_COVERAGE) {
try {
console.log('Loading code coverage task for component');
registerCodeCoverageTasks(on, config);
} catch (error) {
console.warn('Could not load code coverage task:', error.message);
}
}
return config;
},
},
retries: {
runMode: 2,
},
});