1+ import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor" ;
2+ import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild" ;
3+ import createBundler from "@bahmutov/cypress-esbuild-preprocessor" ;
14import { defineConfig } from "cypress" ;
25
36export default defineConfig ( {
@@ -9,25 +12,51 @@ export default defineConfig({
912 "www.google-analytics.com" ,
1013 "sentry.is.canonical.com" ,
1114 ] ,
15+
1216 // We've imported your old cypress plugins here.
1317 // You may want to clean this up later by importing these.
14- setupNodeEvents ( on , config ) {
18+ // Here we use any type as Cypress’s on function supports many different event types, but its TypeScript definitions
19+ // only fully cover "task", so strictly typing on causes errors for other events like "file:preprocessor"
20+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21+ async setupNodeEvents ( on : any , config ) {
22+ await addCucumberPreprocessorPlugin ( on , config ) ;
1523 on ( "task" , {
16- log ( args ) {
24+ log ( args : unknown ) {
1725 console . log ( args ) ;
1826
1927 return null ;
2028 } ,
21- table ( message ) {
29+ table ( message : unknown ) {
2230 console . table ( message ) ;
2331
2432 return null ;
2533 } ,
2634 } ) ;
35+ const jsBundler = createBundler ( { } ) ;
36+
37+ on ( "file:preprocessor" , ( file : Cypress . FileObject ) => {
38+ if ( file . filePath . endsWith ( ".feature" ) ) {
39+ return createBundler ( {
40+ plugins : [ createEsbuildPlugin ( config ) ] ,
41+ } ) ( file ) ;
42+ }
43+
44+ if (
45+ file . filePath . match ( / \. ( j s | t s | j s x | t s x ) $ / ) &&
46+ ! file . filePath . endsWith ( ".steps.ts" )
47+ ) {
48+ return jsBundler ( file ) ;
49+ }
50+
51+ return undefined ;
52+ } ) ;
2753 return config ;
2854 } ,
2955 baseUrl : "http://0.0.0.0:8400" ,
30- specPattern : "cypress/e2e/**/*.{js,jsx,ts,tsx}" ,
56+ specPattern : [
57+ "cypress/e2e/**/*.{js,jsx,ts,tsx}" ,
58+ "cypress/e2e/**/*.feature" ,
59+ ] ,
3160 viewportHeight : 1300 ,
3261 viewportWidth : 1440 ,
3362 } ,
0 commit comments