In version 10, plugins File is removed because Cypress now supports JavaScript and TypeScript configuration files, a separate "plugins file" (which used to default to cypress/plugins/index.js)
Support for the plugins file has been removed, and it has been replaced with the new setupNodeEvents() and devServer config options.
If you wan't to read further about the depreciation of plugins file follow this link.
import { defineConfig } from"cypress";import { addCucumberPreprocessorPlugin } from"@badeball/cypress-cucumber-preprocessor";import browserify from"@badeball/cypress-cucumber-preprocessor/browserify";asyncfunctionsetupNodeEvents( on:Cypress.PluginEvents, config:Cypress.PluginConfigOptions):Promise<Cypress.PluginConfigOptions> {awaitaddCucumberPreprocessorPlugin(on, config);on("file:preprocessor",browserify(config, { typescript:require.resolve("typescript"), }) );// Make sure to return the config object as it might have been modified by the plugin.return config;}exportdefaultdefineConfig({ e2e: { specPattern:"**/*.feature", setupNodeEvents, },});ter
Now that everything are set, we can start writing our test.
Write a test
Write Gherkin documents and add a file for type definitions with a corresponding name (read more about how step definitions are resolved in docs/step-definitions.md). Reading docs/cucumber-basics.md is highly recommended.
# cypress/e2e/duckduckgo.featureFeature: duckduckgo.comScenario: visiting the frontpageWhen I visit duckduckgo.comThen I should see a search bar
// cypress/e2e/duckduckgo.tsimport { When, Then } from"@badeball/cypress-cucumber-preprocessor";When("I visit duckduckgo.com", () => {cy.visit("https://www.duckduckgo.com");});Then("I should see a search bar", () => {cy.get("input").should("have.attr","placeholder","Search the web without being tracked" );});
Running a test in browserless mode:
npx cypress run --browser chrome
Running the test with browser that directs into the spec file:
npx cypress run --browser chrome --e2e
For further details and changes about the migration, your can read it in here.