-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix missing
it.skip
function in Angular tests (#23829)
* fix: restore mocha methods * Simplify `it.skip` patch, add tests * Consolidate test runs for perf * Add tests to validate `skip` and `only` behaviors Co-authored-by: Zachary Williams <zachjw34@gmail.com>
- Loading branch information
1 parent
6ee305b
commit 64c0f45
Showing
4 changed files
with
192 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
system-tests/project-fixtures/angular/src/app/zonejs-mocha-only.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { AppComponent } from './app.component' | ||
|
||
const ExcludedTestTitle = 'should not exist' | ||
|
||
// Validating Mocha syntax and behavior of *.only is still valid after being patched by `zone.js/testing` | ||
// Github Issue: https://github.com/cypress-io/cypress/issues/23409 | ||
describe('only', () => { | ||
context.only('01 - executions', () => { | ||
describe('suite', () => { | ||
suite.only('should exist on "suite"', () => { | ||
it('succeeds', () => {}) | ||
}) | ||
|
||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
|
||
describe('describe', () => { | ||
describe.only('should exist on "describe"', () => { | ||
it('succeeds', () => {}) | ||
}) | ||
|
||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
|
||
describe('context', () => { | ||
context.only('should exist on "context"', () => { | ||
it('succeeds', () => {}) | ||
}) | ||
|
||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
|
||
describe('specify', () => { | ||
specify.only('should exist on "specify"', () => {}) | ||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
|
||
describe('test', () => { | ||
test.only('should exist on "test"', () => {}) | ||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
|
||
describe('it', () => { | ||
it.only('should exist on "it"', () => {}) | ||
it(ExcludedTestTitle, () => {}) | ||
}) | ||
}) | ||
|
||
context.only('02 - validations', () => { | ||
const verifyNotPresent = (title: string) => { | ||
cy.wrap(Cypress.$(window.top!.document.body)).within(() => | ||
cy | ||
.contains(title) | ||
.should('not.exist') | ||
) | ||
} | ||
|
||
describe('suite', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
|
||
describe('describe', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
|
||
describe('context', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
|
||
describe('specify', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
|
||
describe('test', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
|
||
describe('it', () => { | ||
it('should not include other test', () => { | ||
verifyNotPresent(ExcludedTestTitle) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
it('empty passing test', () => {}) |
86 changes: 86 additions & 0 deletions
86
system-tests/project-fixtures/angular/src/app/zonejs-mocha-skip.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { AppComponent } from './app.component' | ||
|
||
// Validating Mocha syntax and behavior of *.skip is still valid after being patched by `zone.js/testing` | ||
// Github Issue: https://github.com/cypress-io/cypress/issues/23409 | ||
describe('skip', () => { | ||
context('01 - executions', () => { | ||
describe('suite', () => { | ||
suite.skip('should exist on "suite"', () => { | ||
it('skipped', () => {}) | ||
}) | ||
}) | ||
|
||
describe('describe', () => { | ||
describe.skip('should exist on "describe"', () => { | ||
it('skipped', () => {}) | ||
}) | ||
}) | ||
|
||
describe('context', () => { | ||
context.skip('should exist on "context"', () => { | ||
it('skipped', () => {}) | ||
}) | ||
}) | ||
|
||
describe('specify', () => { | ||
specify.skip('should exist on "specify"', () => {}) | ||
}) | ||
|
||
describe('test', () => { | ||
test.skip('should exist on "test"', () => {}) | ||
}) | ||
|
||
describe('it', () => { | ||
it.skip('should exist on "it"', () => {}) | ||
}) | ||
}) | ||
|
||
context('02 - validations', () => { | ||
const verifyWasSkipped = (title: string) => { | ||
cy.wrap(Cypress.$(window.top!.document.body)).within(() => | ||
cy | ||
.contains(title) | ||
.parents('[data-model-state="pending"]') // Find parent row with class indicating test was skipped | ||
.should('be.visible') | ||
) | ||
} | ||
|
||
describe('suite', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "suite"') | ||
}) | ||
}) | ||
|
||
describe('describe', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "describe"') | ||
}) | ||
}) | ||
|
||
describe('context', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "context"') | ||
}) | ||
}) | ||
|
||
describe('specify', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "specify"') | ||
}) | ||
}) | ||
|
||
describe('test', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "test"') | ||
}) | ||
}) | ||
|
||
describe('it', () => { | ||
it('should have been skipped', () => { | ||
verifyWasSkipped('should exist on "it"') | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
it('empty passing test', () => {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64c0f45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
64c0f45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
64c0f45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
64c0f45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
64c0f45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: