[rule-tester.js] checking error mesasges
See original GitHub issueright now, if i want to test error messages returned by the linter i do this:
{code: 'class A {}', errors: [{message: '111'}]}
If the test fails, it’ll result into the following error
AssertionError: Error message should be 111
that has no information about what message actually was there.
I assume this is the line that makes the assertion https://github.com/eslint/eslint/blob/master/lib/testers/rule-tester.js#L407
would it be reasonable to add a better description and possibly a regex matching?
I made a rule that checks for existence of test files corresponding to the file that’s being linted, what i want to do ideally is:
{
code: 'class VeryImportantClass {}',
errors: [
{
message: /^because this file is important it should have a test file at .*\-test\.js$/
}
]
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:17 (17 by maintainers)
Top Results From Across the Web
AssertionError on RuleTester for ESlint rule - Stack Overflow
I have written a custom ESLint rule for a NodeJS application. The rule works as expected. However, I am facing issue running Unit...
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
"suggestion" means the rule is identifying something that could be done in a better way but no errors will occur if the code...
Read more >How to use the eslint.RuleTester function in eslint - Snyk
To help you get started, we've selected a few eslint.RuleTester examples, based on popular ways it is used in public projects.
Read more >Write eslint Rules That Meet Needs - Alibaba Cloud Community
Learn the Way to Write Rule Tests. Test before writing. How can we test with actual code when the rules are written? Fortunately,...
Read more >Testing Error Handling in node.js | by Lars Trieloff
“How do I test hard-to-reach error conditions?” However, defensive programming means that you probably spend as much code handling the most likely expected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Huh, that’s interesting. Nice research! I can get behind that.
Other thoughts?
We need to get TSC approval. @eslint/eslint-tsc does anyone object to removing our custom assert message so the actual and expected values are shown automatically?