0

我已将cypress-grep插件安装为开发依赖项,以便我可以运行黄瓜场景特定次数以检查其片状。这些是我所做的更改:

  1. yarn add -D cypress-grep这增加了这种依赖package.json

  2. require('cypress-grep')()在_cypress/support > index.js

  3. (可选)还可以在此处输入以下条目cypress/plugins > index.js

    module.exports = (on, config) => {
      require('cypress-grep/src/plugin')(config)
    }
    
  4. 现在我试图在一个特性文件中多次运行一个场景(标题包含“hello”)来检查它的片状cypress/integration/folderA/sample.feature。为此,我正在执行以下命令:

npx cypress run --spec "cypress/integration/folderA/sample.feature" --env grep=hello,burn=10

但是每次命令运行时,我都会收到以下错误:

The error was:

Error: Webpack Compilation Error
./cypress/integration/folderA/sample.feature 1:15
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> Feature: Feature file name
| 
|   Background: Sample background title

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

我不确定这个错误试图告诉我什么。

4

1 回答 1

0

我能够解决这个问题。如果你想知道它是如何修复的,请参考这个问题:https ://github.com/cypress-io/cypress-grep/issues/62

于 2021-09-01T05:09:15.743 回答