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.

[rule-tester.js] checking error mesasges

See original GitHub issue

right 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

4reactions
nzakascommented, Jun 28, 2016

Huh, that’s interesting. Nice research! I can get behind that.

Other thoughts?

3reactions
nzakascommented, Jul 1, 2016

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?

Read more comments on GitHub >

github_iconTop 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 >

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