eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

Testing enhancement: Testing individual rules or cases

Open brettz9 opened this issue 4 years ago • 5 comments

For eslint-plugin-jsdoc, we have added a convenient testing feature that allows us to run tests like npm run test-index --rule=xyz --invalid=3-5 or npm run test-index --rule=xyz --valid=-1 (with slice-like ranges/indexes/negative indexes). This alone has been extremely helpful for rapid testing and development, and I would suggest it be considered for eslint-plugin-unicorn.

Alternatively, or in addition, one might add only: true or only: 1 to a given tests to behave like Mocha's it.only, changing the default to run no tests except those with an only property.

brettz9 avatar Jan 21 '20 02:01 brettz9

Yes, that would indeed be useful.

sindresorhus avatar Jan 21 '20 10:01 sindresorhus

I have something working locally as a patched version of eslint-ava-rule-tester.

However, as I see no good way to get ava to dynamically ignore a test after the tests have begun, I see no way to avoid getting messages for each ignored file such as "No tests found in test/prefer-trim-start-end.js".

I suppose we could instead dynamically build a CLI glob pattern but besides feeling hacky and requiring some significant changes to the existing test files, this would not become available by default to all eslint-ava-rule-tester users. Is it possible ava could be made to look for something during execution of individual test files so as to ignore displaying their results?

brettz9 avatar Jan 21 '20 12:01 brettz9

I have a VSCode configuration to run/debug an individual test file that I can share if that would be helpful.

jmoore914 avatar Jan 26 '20 19:01 jmoore914

@jmoore914 You wouldn't happen to have that VSCode config still lying around would you?

travismorenz avatar May 29 '22 00:05 travismorenz

@travismorenz I don't, I'm sorry!

jmoore914 avatar May 30 '22 22:05 jmoore914