最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is there any way to run cypress open and only include test files containing a key word? eg. lifecycle from domains-

programmeradmin0浏览0评论

I have a fairly large library of test files in my project (roughly 80) and I have them named with keywords ex. "create" "Edit" and "lifecycle". I want to be able to run npx cypress open and only include all the test files that contain "lifecycle" for example. Is there something I can add to the Cypress.json globing wise?

I have a fairly large library of test files in my project (roughly 80) and I have them named with keywords ex. "create" "Edit" and "lifecycle". I want to be able to run npx cypress open and only include all the test files that contain "lifecycle" for example. Is there something I can add to the Cypress.json globing wise?

Share Improve this question edited May 7, 2022 at 2:23 bad_coder 13k20 gold badges56 silver badges88 bronze badges asked Feb 7, 2020 at 18:49 Justin OswaldJustin Oswald 1791 gold badge5 silver badges13 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 8

To expand on @JosePita's idea, you can set up glob patterns in scripts (package.json) and by-pass the multitude config files he was concerned about.

For example, these work on my system,

"scripts": {
  "cy:open": "cypress open",                              // all files
  "cy:user": "cypress open -c testFiles=user/**/*",       // just the user folder
  "cy:error": "cypress open -c testFiles=**/*error*.js",  // files with keyword 'error'

There's a search bar at the top of the Cypress runner, where the tests are listed, but search is all it does.

Pressing the Run all specs button runs the full set regardless of search results.

If you want to run a subset, specify the testFiles config option on the mand line.

From this it seems you can open it using a config file and from this you can configure what files to load on the configuration.

It's an ugly solution because you'd need to have multiple config files for all the keywords you need (and maintain them).

Another option is to have your test files separated by folders, each with it's own cypress project inside (docs and example)

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论