简体   繁体   English

cypress - “运行所有”功能破坏了我的测试

[英]cypress - "run all" functionality ruins my tests

so here is the deal, in some of my test specs I have a "before all" that should run.所以这就是交易,在我的一些测试规范中,我有一个应该运行的“之前”。 The problem is that when I click the "run all" button tests that do not have this "before all" command are being affected by it as well.问题是,当我单击“全部运行”按钮时,没有“全部”命令的测试也会受到它的影响。

It seems like the "before all" runs before all the test specs files for each test spec.似乎“之前”在每个测试规范的所有测试规范文件之前运行。 How can I run it so that it will work as clicking a single test using the cypress gui.我怎样才能运行它,以便它可以像使用 cypress gui 单击单个测试一样工作。

Using CLI is not an option because at the end my tests need to be run manually each time before a new release.使用 CLI 不是一种选择,因为最后每次发布新版本之前,我的测试都需要手动运行。

Thank you.谢谢你。

Before and BeforeEach are pretty confusing in Cypress.在 Cypress 中, BeforeBeforeEach非常混乱。 Actually there is a great article from Cypress genius Gleb Bahmutov about the topic of before hooks when running all specs.实际上,赛普拉斯天才 Gleb Bahmutov发表了一篇很棒的文章,讨论了运行所有规范时的 before hooks 主题。

Yes, before hooks at the root level will run before every single spec file when you "Run All"是的,当您“全部运行”时,根级别的挂钩将在每个规范文件之前运行

The solution to your problem might be to move the before hook into then "describe" suite.解决您的问题的方法可能是将 before 钩子移到 then "describe" 套件中。

So instead of所以代替

before(() => {
   'Do that before'
    })

describe('actual spec', () => {
   'Actual Test
   })

Try moving it inside试着把它移到里面

describe('actual spec', () => {
   before(() => {
   'Do that before'
   }) 
   'Actual Test'
  })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM