cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.86k stars 3.17k forks source link

it.skip not working in Angular component test #23409

Closed bahmutov closed 2 years ago

bahmutov commented 2 years ago

Current behavior

import { StepperComponent } from './stepper.component'

describe('StepperComponent', () => {
  it.skip('mounts', () => {
    cy.mount(StepperComponent)
    cy.contains('[data-cy=stepper]', 'works')
  })

  it('mounts using a template', () => {
    cy.mount(`<app-stepper data-cy=mounted [count]="101"></app-stepper>`, {
      declarations: [StepperComponent],
    }).then(console.log)
  })
})
Screen Shot 2022-08-17 at 17 10 47

Workaround: use xit instead of it.skip and it skips it

Desired behavior

it.skip should work :)

Test code to reproduce

Following https://docs.cypress.io/guides/component-testing/quickstart-angular in Cypress v10.6.0 package.json file

{
  "name": "test-angular-component",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.1.0",
    "@angular/common": "^14.1.0",
    "@angular/compiler": "^14.1.0",
    "@angular/core": "^14.1.0",
    "@angular/forms": "^14.1.0",
    "@angular/platform-browser": "^14.1.0",
    "@angular/platform-browser-dynamic": "^14.1.0",
    "@angular/router": "^14.1.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.1.3",
    "@angular/cli": "~14.1.3",
    "@angular/compiler-cli": "^14.1.0",
    "@types/jasmine": "~4.0.0",
    "cypress": "^10.6.0",
    "jasmine-core": "~4.2.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "prettier": "^2.7.1",
    "typescript": "~4.7.2"
  }
}

Cypress Version

10.6.0

Node version

16

Operating System

mac

Debug Logs

No response

Other

No response

nickAdlard commented 2 years ago

This is repro in e2e tests, skip no worky. EDIT: It's not repro in e2e but I'm experiencing something a little different: if skip is on the first test, it breaks the beforeEach() that copies the login cookies and causes subsequent tests to fail because it acts like it's not logged in. So something different is going on in my case 🙈.

baus commented 2 years ago

Hey team! Please add your planning poker estimate with ZenHub @amehta265 @astone123 @lmiller1990 @marktnoonan @mike-plummer @rockindahizzy @warrensplayer @ZachJW34

lmiller1990 commented 2 years ago

I think the problem is zone.js is overriding it and not re-applying the skip property. I could be wrong - but this would explain why it's an Angular only problem, and also why it manifests in both E2E and CT if you are using Angular.

ZachJW34 commented 2 years ago

The mocha overrides comes from zone.js/testing, which (to my knowledge) is only included in CT tests.

@nickAdlard if you are seeing an issue with Angular e2e, do you mind creating another issue with a reproduction so we can dig into what's going on?

cypress-bot[bot] commented 2 years ago

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

cypress-bot[bot] commented 2 years ago

Released in 10.9.0.

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