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.

False-positive jest/no-disabled-tests

See original GitHub issue

In a non-test file (trackingXiti.ts), I have a function like this:

const mapPageViewEventName = (...) => {
    ....
    const map = xitiViewMap(...)
    ...
}

The rule warns about the line with the xitiViewMap function, probably because it starts with xit.

  1. Shouldn’t the jest rules only run on *.test.{js,tsx?} files?
  2. The rule should match xit( and not xitSomethingElse(

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Mar 6, 2021

Would be nice If I could somehow generally declare which rules to enable for which files without having to specify it in the files themselves.

That’s what exactly overrides is for 😃

Here’s one of my projects that uses overrides to apply the eslint-plugin-jest rules only to test files (via applying my company’s jest shared config).

1reaction
G-Rathcommented, Mar 6, 2021

We do hope to read the config one day to enhance the rules - see here for why that’s currently not possible.

However, I don’t think we’d do that for determining what files to run on, as that is exactly what you’re meant to be using overrides for and some of our rules don’t require being rule on files that jest runs as tests (i.e test helpers).

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-jest/no-disabled-tests.md at main
This rule raises a warning about disabled tests. Rule details. There are a number of ways to disable tests in Jest: by appending...
Read more >
How to Test Asynchronous Code with Jest
If you want to avoid Jest giving a false positive, by running tests without assertions, you can either use the expect.hasAssertions() or expect....
Read more >
Jest CLI Options
Run only the tests that were specified with a pattern or filename: ... jest path/to/my-test.js ... Disable the cache using --no-cache .
Read more >
5 tips for a healthier DivOps setup
In my opinion, a codebase with false-positive tests or tests that ... from accidentally committing skipped tests ( jest/no-disabled-tests ).
Read more >
@testing-library/jest-dom - npm
Note: We also recommend installing the jest-dom eslint plugin which provides auto-fixable lint rules that prevent false positive tests and ...
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