Skip to content

cypress skipOn demo #46

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"project": ["**/tsconfig.json"],
"sourceType": "module",
"createDefaultProgram": true
},
"env": {
Expand All @@ -27,7 +25,6 @@
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:cypress/recommended",
"plugin:jest/recommended",
"plugin:jest/style"
],

Expand Down
5 changes: 4 additions & 1 deletion cypress/config/dev.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "../../cypress.json",
"baseUrl": "https://d1kaucldkbcik4.cloudfront.net",
"projectId": "4mhoqq"
"projectId": "4mhoqq",
"env": {
"ENVIRONMENT": "dev"
}
}
5 changes: 4 additions & 1 deletion cypress/config/local.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"baseUrl": "http://localhost:4200",
"extends": "../../cypress.json",
"projectId": "4mhoqq"
"projectId": "4mhoqq",
"env": {
"ENVIRONMENT": "local"
}
}
18 changes: 18 additions & 0 deletions cypress/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export {};

declare global {
namespace Cypress {
interface Chainable<Subject> {
// the cypress skip-test plugin has an open issue with types, that is we have declare these here
// https://github.com/cypress-io/cypress-skip-test/issues/164
/** https://www.npmjs.com/package/@cypress/skip-test
* `cy.skipOn('sandbox')`
*/
skipOn(nameOrFlag: string | boolean | (() => boolean), cb?: () => void): Chainable<Subject>;
/** https://www.npmjs.com/package/@cypress/skip-test
* `cy.onlyOn('sandbox')`
*/
onlyOn(nameOrFlag: string | boolean | (() => boolean), cb?: () => void): Chainable<Subject>;
}
}
}
10 changes: 7 additions & 3 deletions cypress/integration/about.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
describe('about', () => {
import { skipOn } from '@cypress/skip-test';

describe('about', () => {
before('visit about', () => {
cy.visit('/');
cy.get('[routerlink="/about"]').click();
Expand All @@ -8,11 +9,14 @@ describe('about', () => {
});

it('should get a different quote on next', () => {
cy.get('.twain > i').then(initialQuote => {
// use cy.skipOn to reproduce the issue
// cy.skipOn('local');
skipOn('local');
cy.get('.twain > i').then((initialQuote) => {
cy.get('button').click();

cy.get('.twain > i').should('not.contain', '...');
cy.get('.twain > i').should('not.contain', initialQuote);
})
});
});
});
1 change: 1 addition & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
// import './commands';

import '@cypress/code-coverage/support'
import '@cypress/skip-test/support'
6 changes: 4 additions & 2 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"include": ["./**/*.ts"],
"exclude": [],
"compilerOptions": {
"types": ["cypress"],
"types": ["cypress", "@cypress/skip-test"],
"lib": ["es2015", "dom"],
"isolatedModules": false,
"allowJs": true,
"noEmit": true
}
},
"allowJs": true,
"resolveJsonModule": true
}
54 changes: 50 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@angular/language-service": "11.2.2",
"@bahmutov/cypress-extends": "1.1.0",
"@cypress/code-coverage": "3.9.11",
"@cypress/skip-test": "^2.6.1",
"@ngneat/spectator": "^7.1.0",
"@skyux-sdk/istanbul-instrumenter-loader": "^4.0.0",
"@types/jest": "^26.0.21",
Expand Down