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

Nested .only is still ignored #28009

Closed
BloodyRain2k opened this issue Oct 9, 2023 · 2 comments
Closed

Nested .only is still ignored #28009

BloodyRain2k opened this issue Oct 9, 2023 · 2 comments

Comments

@BloodyRain2k
Copy link

BloodyRain2k commented Oct 9, 2023

Current behavior

According to #3818 the test code below shouldn't be an issue, but it still is.

Only the "outer .only" is ran, the other is ignored.
Even when I'm trying to "help" Cypress by marking the "nested .only"'s describe with .only too.

Was the referenced issue only about the fact that back then Cypress was limited to running just the first .only it encountered?
Because that at least is working fine, multiple .only on the same "level" are ran as expected, but it doesn't seem to check "deeper levels" after that.

Desired behavior

The behavior I was expecting was that it would simply run all tests or test sets that are marked with .only, regardless of nesting.

Test code to reproduce

describe("main test", () => {
  describe("nested test", () => {
    it.only("nested .only", () => {
      // this should run too, but doesn't
      cy.log(Cypress.currentTest.title);
    });
  });
  
  it.only("outer .only", () => {
    cy.log(Cypress.currentTest.title);
  });
});

Cypress Version

12.17.3

Node version

14.21.1

Operating System

Win 10 - 19045.3448

Debug Logs

No response

Other

No response

@Crustum7
Copy link
Contributor

Crustum7 commented Oct 9, 2023

Was the referenced issue only about the fact that back then Cypress was limited to running just the first .only it encountered?

That is correct. The newer versions of mocha prioritizes test case over test suite but I can't find any references in their documentation to nested tests like you have (https://mochajs.org/#exclusive-tests).

I think the intended use for the .only-feature is to have all your tests on the same nest level. Why don't you wrap the "outer .only" in its own describe?

@BloodyRain2k
Copy link
Author

I think the intended use for the .only-feature is to have all your tests on the same nest level. Why don't you wrap the "outer .only" in its own describe?

That's what I was hoping to avoid as most tests in that suite were stand-alone tests, except for 1 or 2 that were a small set.
But I guess since I don't want to find out where to fix the code that prevents nesting, I'll just have to group the stand-alones into their own suite and the small sets come after.

So I guess I can close this "issue" then, since it's more of a QoL than an actual bug. Or is there a tag for that and I'll just leave it open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants