Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot (failed) captured during skipped tests #17660

Closed
jennifer-shehane opened this issue Aug 9, 2021 · 8 comments · Fixed by #19279 or #19331
Closed

Screenshot (failed) captured during skipped tests #17660

jennifer-shehane opened this issue Aug 9, 2021 · 8 comments · Fixed by #19279 or #19331
Assignees

Comments

@jennifer-shehane
Copy link
Member

Current behavior

In some circumstances invovling skipped tests and the Cypress 'fail' event listener a failure screenshot will be taken when it shouldn't be.

Desired behavior

  1. A failure screenshot should never be taken when the test is skipped.
  2. The fail event handler shouldn't be triggered during skipped tests.

Test code to reproduce

spec.js

Cypress.on('fail', () => {
  throw new Error('error')
})

describe('tests', () => {
  before(function () {
    this.skip()
  })
  it('failing test', () => {
    expect(true).to.be.false
  })
})

Screen Shot 2021-08-09 at 2 14 45 PM

Cypress Version

8.2.0

Other

No response

@jmoses
Copy link

jmoses commented Sep 23, 2021

I'm seeing this with 8.4.1 using the https://github.com/cypress-io/cypress-skip-test plugin, as well.

@cesine
Copy link

cesine commented Oct 20, 2021

I have this issue as well, i am not able to use this.skip() in an it like this:

describe('tests', () => {

  it('failing test', function () {
    if (process.env.FOO_ENABLED === 'false') {
      this.skip();
    }
    console.assert(false);
  });
});

I get the feeling that the docs are over simplifying, maybe there is not really Mocha under Cypress. https://docs.cypress.io/faq/questions/general-questions-faq#Mocha

Cypress isn't different from Mocha, it actually uses Mocha under the hood. All of your tests will be written on top of Mocha's bdd interface.

I can see references to mocha https://github.com/cypress-io/cypress/search?q=mocha

I made a sample repo which demos how Mocha skips work, in case you want to use it to find out why Cypress isn't able to support this.skip() https://github.com/cesine/mocha-skip-demo

@rkrisztian
Copy link

Same bug when using cypress-cucumber-preprocessor, which I use to filter tests by tags, thus I'm having plenty of failed screenshots when none of my tests fail.

@petetnt
Copy link

petetnt commented Nov 5, 2021

I think I am running into this, but even in a weirder form on 8.7.0.

In my case, is have two test specs, called Foo and Bar.

In Foo.spec.ts, I have a failing case:

describe('Foo', () => {
  it('foo fails', () => {
    throw new Error('Fail');
  });
});

I have bar.spec.ts

describe('Bar', () => {
  it.skip('skip', () => {
    // noop 
  });
});

When running the tests, I had the following screenshot saved:

screenshots/bar.spec.ts/Foo -- foo fails (failed).png

The test output shows that Bar - skip failed and the Foo - foo fails succeeded.

I have no idea what's going on with that.

@ryanthemanuel ryanthemanuel self-assigned this Dec 2, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 6, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: pending release and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 7, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 10, 2021

The code for this is done in cypress-io/cypress#19279, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@ryanthemanuel
Copy link
Collaborator

@petetnt I have a fix for the issue in the main description coming in on #19331. I could not reproduce your use case exactly. When this lands, if you still are having the same problem, feel free to open a separate issue.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Dec 10, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 10, 2021

The code for this is done in cypress-io/cypress#19331, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2021

Released in 9.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.