-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
116 lines (106 loc) · 2.81 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
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
110
111
112
113
114
115
116
import { defineConfig } from "cypress";
import * as Webpack from "webpack";
import { devServer } from "@cypress/webpack-dev-server";
import webpackPreprocessor from "@cypress/webpack-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
//
const webpackConfig = (
cypressConfig: Cypress.PluginConfigOptions
): Webpack.Configuration => {
return {
resolve: {
extensions: [".js", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader",
options: { transpileOnly: true },
},
],
},
{
test: /\.feature$/,
use: [
{
loader: "@badeball/cypress-cucumber-preprocessor/webpack",
options: cypressConfig,
},
],
},
],
},
};
};
async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Promise<Cypress.PluginConfigOptions> {
// This is required for the preprocessor to be able to generate JSON reports after each run, and more,
await addCucumberPreprocessorPlugin(on, config);
const options = {
webpackOptions: {
resolve: {
extensions: [".ts", ".js"],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: "ts-loader",
},
],
},
{
test: /\.feature$/,
use: [
{
loader: "@badeball/cypress-cucumber-preprocessor/webpack",
options: config,
},
],
},
],
},
},
};
on("file:preprocessor", webpackPreprocessor(options));
// Make sure to return the config object as it might have been modified by the plugin.
return config;
}
export default defineConfig({
component: {
specPattern: "**/*.feature",
supportFile: false,
devServer(devServerConfig) {
return devServer({
...devServerConfig,
framework: "react",
webpackConfig: webpackConfig(devServerConfig.cypressConfig),
});
},
async setupNodeEvents(on, config) {
// This is required for the preprocessor to be able to generate JSON reports after each run, and more.
await addCucumberPreprocessorPlugin(on, config);
// Make sure to return the config object as it might have been modified by the plugin.
return config;
},
},
e2e: {
specPattern: "**/*.feature",
supportFile: false,
setupNodeEvents,
},
// e2e: {
// setupNodeEvents(on, config) {
// // implement node event listeners here
// },
// },
});