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

Cypress it.skip fails #3198

Closed
MikeMcC399 opened this issue Nov 3, 2022 · 6 comments
Closed

Cypress it.skip fails #3198

MikeMcC399 opened this issue Nov 3, 2022 · 6 comments

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 3, 2022

Where to find the issue

Cypress tests under development in cypress/e2e.

Describe the issue

If a Cypress test is changed from it to it.skip for debugging purposes, other tests which do not have the skip attribute applied do not run and the following error is produced:

TypeError
The following error originated from your test code, not from Cypress.

> Cannot set properties of undefined (setting 'body')

This is a development issue only. It does not affect the website itself.

Steps to reproduce

Create a new test spec test.skip.cy.js in cypress/e2e/ with the following contents:

it("test 1 - run this", () => { 
    cy.log("test 1 log")
});
it.skip("test 2 - skip this", () => { 
    cy.log("test 2 log")
});

Execute npm run test:open
Select test.skip.cy.js

This produces the error > Cannot set properties of undefined (setting 'body') and no tests are executed.

Regression with Cypress 10.11.0

Going back one minor version from Cypress 10.11.0 to 10.10.0 removes the issue:

Execute:
npm install cypress@10.10.0

Repeat the above test.

test 1 runs, test 2 is skipped. This is correct.

Regression with monkey-patch

npm install cypress@latest
Edit cypress/support/e2e.js and remove all code starting with the comment line
// soft assert for finding broken links, see also check_links.js
to the end of the file.

Repeat the test.

test 1 runs, test 2 is skipped. This is correct.

Code issue

cypress/support/e2e.js

contains the code

const origIt = window.it;
window.it = (title, func) => {
origIt(title, func && (() => itCallback(func)));
};
window.it.only = (title, func) => {
origIt.only(title, func && (() => itCallback(func)));
};
window.it.skip = (title, func) => {
origIt.skip(title, func);
};
beforeEach(() => {
errors = [];
});
afterEach(() => {
errors = [];
isSoftAssertion = false;
});

that modifies the standard behaviour of Cypress / mocha.

Without this code, it.skip works as expected.

Reference

Cypress documentation

Excluding and Including Tests

"To skip a specified suite or test, append .skip() to the function. All nested suites will also be skipped."

Suggestion

Since this is a minor development issue only, I suggest no change at this time.


Internal Tracking ID: EXPOSUREAPP-14292

@MikeMcC399
Copy link
Contributor Author

I will try to get feedback on this issue from public forums. The monkey-patch was posted on Stackoverflow, however it is unsupported code which goes deeply into the workings of Cypress. It doesn't seem like there is any open source maintenance for this code at this time.

@MikeMcC399
Copy link
Contributor Author

@MikeMcC399
Copy link
Contributor Author

@brianebeling
Copy link
Member

Hey @MikeMcC399

Internally, we don't work with test skipping. We would support downgrading a minor version, assuming no functionality breaks. Do you want to work on that and verify nothing breaks? Otherwise, we can do it when we have some space for it, but it wouldn't be a high priority for us.

@MikeMcC399
Copy link
Contributor Author

MikeMcC399 commented Nov 7, 2022

@brianebeling

I wouldn't want to downgrade Cypress to 10.10.0 and it wouldn't solve the related it.only issue. In the meantime a community member who already proposed a solution for the it.only issue said that they would look at solving the it.skip issue as well (see cypress-io/cypress#23280 (reply in thread)), so I would hold back.

I agree that this is not high impact or urgency and I have only shared it for completeness.

Thanks anyway for your attention!

@brianebeling
Copy link
Member

@MikeMcC399

Great, thank you! I wasn't aware there is already activity from cypress's side. Then we will monitor how things go and come back to the issue when there is a fix.

@MikeMcC399 MikeMcC399 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants