question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

describe.only() does not work when string is the same as another describe() block

See original GitHub issue

Current behavior:

If you have multiple describe blocks with the same description string, marking one of them with describe.only will run all describe blocks with the same description instead of just the one with .only:

image

Desired behavior:

Marking a describe block with .only should “only” run that describe block, not others with the same description.

Steps to reproduce: (app code and test code)

Run the following spec:

describe('outer describe', () => {
  describe('inner describe', () => {
    it('works', () => {});
  });

  describe.only('inner describe', () => {
    it('works again', () => {});
  });

  describe('unique name', () => {
    it('still works', () => {});
  });

  describe('inner describe', () => {
    it('works yet again', () => {});
  });
});

Instead of just running one test with the description “works again”, three tests are executed, in all three describe('inner describe'...) blocks.

Versions

Cypress 3.4.1 Ubuntu 18.04 Chrome 77

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Oct 10, 2019

Cypress uses a Mocha version 2.5.3, this is fixed in later versions. Going to close this as a duplicate of https://github.com/cypress-io/cypress/issues/2528 - which will be released in Cypress 4.0.0 release.

0reactions
flotwigcommented, Feb 6, 2020

Released in 4.0.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

describe.only() does not work when string is the same as ...
With two describe() blocks that have identical strings, when one of them is a describe.only() , only that one's tests should run,
Read more >
Why can't nested describe() blocks see vars defined in outer ...
The problem is that your var trees variable is trying to access orchard before it has been initialized. The body of a describe...
Read more >
Mocha documentation — DevDocs
only() used string matching to decide which tests to execute; this is no longer the case. In v3.0.0 or newer, .only() can be...
Read more >
Strict mode - JavaScript - MDN Web Docs
JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
Read more >
Globals · Jest - API Manual
If afterEach is inside a describe block, it only runs after the tests that are ... that our tests don't modify it. test('can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found