Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/stubs/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { defineConfig } = require('cypress')
import { defineConfig } from 'cypress';
import plugins from './%cypressPath%/plugins/index.js';

module.exports = defineConfig({
export default defineConfig({
chromeWebSecurity: false,
retries: 2,
defaultCommandTimeout: 5000,
Expand All @@ -10,7 +11,7 @@ module.exports = defineConfig({
fixturesFolder: '%cypressPath%/fixture',
e2e: {
setupNodeEvents(on, config) {
return require('./%cypressPath%/plugins/index.js')(on, config)
return plugins(on, config)
},
baseUrl: '%baseUrl%',
specPattern: '%cypressPath%/integration/**/*.cy.{js,jsx,ts,tsx}',
Expand Down
7 changes: 4 additions & 3 deletions src/stubs/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
Expand All @@ -12,12 +11,14 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

import swapEnv from './swap-env.js';

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
export default (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

on('task', require('./swap-env'));
on('task', swapEnv);
};
4 changes: 2 additions & 2 deletions src/stubs/plugins/swap-env.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let fs = require('fs');
import fs from 'fs';

module.exports = {
export default {
activateCypressEnvFile() {
if (fs.existsSync('.env.cypress')) {
fs.renameSync('.env', '.env.backup');
Expand Down