我正在将 Cypress 集成到我的项目中以执行组件测试,并相应地编写了一些测试。当我使用 cypress open 命令运行测试时,我能够成功执行组件测试。但是,当我尝试使用 cypress run 命令运行组件测试时,遇到以下错误:
您的配置文件中未配置所选的测试类型(e2e)。 请运行“cypress open”并选择您的测试类型以自动更新您的配置文件。 https://on.cypress.io/configuration
我只想进行组件测试,跳过 e2e 测试
我在网上搜索了解决方案,但没有找到覆盖它的方法。如何解决此问题并使用 cypress run 命令成功运行组件测试?
赛普拉斯配置如下所示:
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)
},
},
});