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-disabled-tests doesn't recognice spreading

See original GitHub issue

We have defined a couple of tests that we run for a lot of components we build. Those tests get auto generated by a method and the return value gets spreaded into the test method. Unfortunatly the rule no-disabled-tests can not resolve the spreading and therefore throws an error ( Test is missing function argument eslint(jest/no-disabled-tests) ).

minimal example:

const test = [
	"title",
	() => { expect(true).toBe(true); },
];
describe("@components/someComponent", () => {
	it(...test); // warning  Disabled test suite          jest/no-disabled-tests
})

a more practial example would be this:

import PulsatingDot from "./PulsatingDot";
describe("@components/atoms/PulsatingDot", () => {
	// isValidComponent returns 
	// ["PulsatingDot exports a valid component", () => { ... }]
	it(...isValidComponent(PulsatingDot));
});

Is there an easy way to fix this on our side or is the rule just not compatible with this approach?


Research I did:

  • The error seems to be coming from here and is thrown because the spreading isn’t detected as multiple arguments. Maybe there is another method to check the number of parameters?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Dec 24, 2020

I’m going to close this at wontfix as I don’t think it’s a pattern we want to encourage.

You could easily work around this by changing isValidComponent to contain the it:

const isValidComponent = (...) => {
  it("title", (​)​ ​=>​ ​{​ ​expect​(​true​)​.​toBe​(​true​)​;​ ​}​):
}

IMO this is better anyway as it encapsulates the responsibility of the function.

0reactions
adrianjostcommented, Jan 13, 2020

@G-Rath Yes kindof. We have a global function called isValidComponent which will receive a Component as a parameter and uses this component to generate and return an Array that includes the testname with the populated component name as the first entry and a test function populated with the component to test as the second parameter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-jest/no-disabled-tests.md at main - GitHub
Before committing changes we may want to check that all tests are running. This rule raises a warning about disabled tests.
Read more >
Is there a way to ignore test files for eslint-plugin-security?
The best way I found to deal with this case is based on this answer. You can override parts of your eslint file...
Read more >
Covid-19 testing: Here's why you can be contagious but still ...
Don't get a false sense of security with Covid-19 testing. Here's why you can test negative but still be infected and contagious.
Read more >
Coronavirus FAQ: Testing confuses me! When to do it ... - NPR
With COVID case counts falling and rising, testing is critical. But how many days after exposure should I test? And if I have...
Read more >
What you should know about rapid antigen tests - PBS
So what can Americans be doing now to slow or limit the spread of ... It doesn't tell us whether we're contagious or...
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