Encountering Error While Running Cypress Component Tests Using ‘cypress run’ Command

  Kiến thức lập trình

I’m integrating Cypress into my project to perform component testing and have written a few tests accordingly. When I run tests using the cypress open command, I’m able to execute component tests successfully. However, when I attempt to run component testing using the cypress run command, I encounter the following error:

The testing type selected (e2e) is not configured in your config file.
Please run ‘cypress open’ and choose your testing type to automatically update your configuration file.
https://on.cypress.io/configuration

I’ve searched online for a solution but haven’t found a way to override it. How can I resolve this issue and successfully run component tests using the cypress run command?

Cypress config looks like this:

import { defineConfig } from "cypress";
import {addMatchImageSnapshotPlugin} from '@simonsmith/cypress-image-snapshot/plugin';


export default defineConfig({
  component: {
    devServer: {
      framework: "react",
      bundler: "webpack",
    },
    setupNodeEvents(on) {
      addMatchImageSnapshotPlugin(on)
    },
  },
});

LEAVE A COMMENT