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.

`no-identical-title` maybe could be ignored for nested `describe` blocks...?

See original GitHub issue

My scenario is that the linter is whining about no-identical-titles for nested describes where that nested title is actually what i want.

Imagine this:

describe("my component", () => {
  describe("west facing", () = {
    describe("when the sun is up", () => {  
       it("sees the sun", () => {});
    })
    describe("when the sun is down", () => {  
       it("sees the moon", () => {});
    });
  });
  describe("east facing", () = {
    describe("when the sun is up", () => {  
       it("does not see the sun", () => {});
    })
    describe("when the sun is down", () => {  
       it("sees whatever", () => {});
    });
  });
});

In this case… the linter doesn’t like when the sun is up and when the sun is down because they are the same, but as nested describes, they seem like a valid use case.

What do you think of that? could there be a rule that looks at the full “nested” title to determine it’s allowed “uniqueness”?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
SimenBcommented, Apr 19, 2018

That definitely makes sense! We should try to match against full names (so my component > west facing > when the sun is up > sees the sun) and not against describes and its in isolation.

Not sure how hard that is, but PR welcome!

0reactions
bunnymaticcommented, Apr 20, 2018

Fine with me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't nested describe() blocks see vars defined in outer ...
The below code works fine. I've set up a variable in my root describe() block that is accessible within my sub- describe() s'...
Read more >
You can't nest describe blocks in ExUnit
I write JavaScript in my day job and nesting describe blocks in my tests is such common practise, that I hardly even think...
Read more >
@jest/expect-utils | Yarn - Package Manager
This module exports some utils for the expect function used in Jest. You probably don't want to use this package directly. E.g. if...
Read more >
Codiga Analysis JavaScript Rules
The Codiga Static Analysis engine checks JavaScript code and supports many popular libraries. If you are using React, NextJS, Vue or Angular: the...
Read more >
Angular Testing Part 2: Jasmine Syntax - Dave Ceddia
If you haven't done much or any testing up til now, Jasmine's syntax can look a little strange. There's nested describe , it...
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