Home > OS >  Cypress - I'm aware about some bugs in the app, and I don't want to display those failures
Cypress - I'm aware about some bugs in the app, and I don't want to display those failures

Time:10-23

I write tests in Cypress.

Let's say there are 30 tests. 10 of those tests will fail cause there are bugs in the app, but tests are written properly. I'm aware of those bugs. Is there a possibility that a final report in cypress doesn't display failed tests as failed (those which I'm aware of), and display only "new ones".

I could comment off tests that fail and it would solve the problem, but is there any other way? Let's say Mark some tests as "always pass" or something?

The main reason why I want to do this is to display only bugs that are "new", and separate them from the old ones that I'm aware of.

enter image description here

CodePudding user response:

You can use .skip or .only for these. Skip will skip the test cases. Only will only execute that particular test case

  1. With skip, only Test Case 3 will be executed:
describe('Test Suite', () => {
  before(function () {
    //Some code
  })

  beforeEach(function () {
    //Some code
  })

  it.skip('Test Case 1', function () {
    //some code
  })

  it.skip('Test Case 2', function () {
    //some code
  })

  it('Test Case 3', function () {
    //some code
  })
})
  1. With only, only Test Case 2 will be executed:
describe('Test Suite', () => {
  before(function () {
    //some code
  })

  beforeEach(function () {
    //some code
  })

  it('Test Case 1', function () {
    //some code
  })

  it.only('Test Case 2', function () {
    //some code
  })

  it('Test Case 3', function () {
    //some code
  })
})

CodePudding user response:

I could comment off tests that fail and it would solve the problem, but is there any other way?

How about troubleshooting those that fail and taking one of the following actions to resolve it:

  • fix the app
  • fix the Cypress checks

I don't think there is any other option. Automated checks should provide some information for you, if they don't, they should not exist. If they do and you ignore the information, you don't need them anyway.

Mark some tests as "always pass" or something?

Do not do that. Is it like having no checks at all. If you don't need the information, why bother at all? Just delete them, or don't run them.

Let's say there are 30 tests. 10 of those tests will fail cause there are bugs in the app, but tests are written properly.

Here you go. Go fix the app.


Alright, if you need to skip some of them, you can use cypress-grep to choose only some checks based on their names or tags.

For example, I can add a tag to a check:

it('Test Case 1', { tags: ['@core'] }, () => {

})

and add a new script to package.json:

{
  "scripts": {
    "run:core": "cypress run --env grepTags=@core",
    "run:all-but-core": "cypress run --env grepTags=-@core"
  }
}

and so on. There are more examples in the docs. Grepping checks could be useful in situations like:

  • you want to run different set of checks on different environments
  • you have smoke, sanity, and some other set of checks
  • you want to run checks for only a particular part of the app
  • you want to skip some checks => that's your situation here
  • Related