-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rule-tester.js] checking error mesasges #6532
Comments
It sounds like you're asking for two things. Can you please open a separate issue for regex matching? I think what you're asking for otherwise is to output actual and expected values? I could have sworn it did this by default already. |
Related: #6106 |
@nzakas i think it's mocha integration that provides a nice |
Ah, I see. How are you using RuleTester? |
i run it with jest and it seems like it automatically hooks it up to jest's global |
Yeah, it uses whatever global |
@nzakas Could we support a RuleTester property (e.g., |
I think this way |
@DmitriiAbramov I'm not sure if you're replying to me or @platinumazure, so hard to respond. @platinumazure we could, I'm just not sure it's worth it. My overall thought here is that it's the testing frameworks who should be responsible for pretty-displaying actual vs. expected values rather than us trying to cram all that information into the message. Here's an example of what I see in Mocha:
To me, that error message is already too long but the showing of the actual vs. expected is the useful part (provided by Mocha). This still seems to me like an issue with testing frameworks rather than @eslint/eslint-team other thoughts? |
I agree with @nzakas, any changes to this would be extra complexity to work around something that should really be in the testing framework. |
as an alternative i can propose to remove > const expected = 'EXPECTED', actual = 'ACTUAL'; assert.equal(expected, actual);
AssertionError: 'EXPECTED' == 'ACTUAL'
at repl:1:56
at REPLServer.defaultEval (repl.js:269:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:439:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)
> So basically. if decided to delegate the formatting to testing frameworks, let's not change the default message given by what's going on in rule tester right now is: > const expected = 'EXPECTED', actual = 'ACTUAL'; assert.equal(expected, actual, `expected should be ${actual}`);
AssertionError: expected should be ACTUAL
at repl:1:56
at REPLServer.defaultEval (repl.js:269:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:439:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14) and it's a pain to work on error message testing without using mocha. Whatever the decision is, i'm more than happy to submit a PR |
Huh, that's interesting. Nice research! I can get behind that. Other thoughts? |
@nzakas awesome! if you're ok with that, i'll send a PR to use default error messages. |
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? |
Sounds like a good plan to me. Even using mocha I don't always get expected/actual, sounds like that should fix it. |
Cool, let's do it. @DmitriiAbramov if you want to submit a PR, we're ready for it now. |
right now, if i want to test error messages returned by the linter i do this:
If the test fails, it'll result into the following error
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:
The text was updated successfully, but these errors were encountered: