-
Notifications
You must be signed in to change notification settings - Fork 117
/
cypress.config.ts
84 lines (80 loc) · 2.11 KB
/
cypress.config.ts
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
import { defineConfig } from 'cypress';
import fs from 'fs';
import webpack from 'webpack';
const task = {
log(message: string) {
//eslint-disable-next-line no-console
console.log(message);
return null;
},
table(message: string) {
//eslint-disable-next-line no-console
console.table(message);
return null;
},
};
export default defineConfig({
retries: {
runMode: 2,
openMode: 0,
},
numTestsKeptInMemory: 1,
component: {
setupNodeEvents(on, config) {
on('task', task);
on('after:spec', (_, results: CypressCommandLine.RunResult) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed')
);
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
}
});
return config;
},
devServer: {
framework: 'react',
bundler: 'webpack',
webpackConfig: {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],
},
// needed to prevent ReferenceErrors
// cf. https://github.com/webpack/webpack/issues/6693#issuecomment-745688108
output: {
hotUpdateChunkFilename: '[id].[fullhash].hot-update.js',
hotUpdateMainFilename: '[runtime].[fullhash].hot-update.json',
},
performance: false,
module: {
rules: [
{
test: /\.t|jsx?$/,
exclude: [/node_modules/],
use: [
{
loader: 'swc-loader',
},
],
},
{
test: /\.mjs$/,
type: 'javascript/auto',
},
],
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
}),
],
},
},
specPattern: 'cypress/component/**/*.spec.{js,ts,jsx,tsx}',
},
video: true,
});