Skip to content
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

Update: improve suggestion testing experience #12602

Merged
merged 1 commit into from Dec 20, 2019

Conversation

@bradzacher
Copy link
Contributor

@bradzacher bradzacher commented Nov 25, 2019

Previously you had to explicitly set suggestions: undefined, or omit the property.
I hate writing undefined in my code, but I also prefer to be explicit in my tests, and explicitly say "I expect no suggestions".

This just lets a user pass any falsey value, or an empty array.
The rule tester will interpret any of these values as "I expect no suggestions".

I.e. these will now be equivalent:

ruleTester.run("suggestions-basic", rule, {
  valid: [],
  invalid: [
    // previously only allowed:
    {},
    {
      suggestions: undefined,
    },
    // now also allows
    {
      suggestions: [],
    },
    {
      suggestions: null,
    },
    {
      suggestions: false,
    },
  ],
});
Previously you had to explicitly pass the exact same value (undefined), which meant either explicitly set `suggestions: undefined`, or omit the property.
I hate writing `undefined`, but I prefer to be explicit in my tests and say "I expect no suggestions".
Now you can pass any falsey, or an empty array, and the rule tester will perform as expected.
@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Nov 25, 2019

This seems like a good idea to me. I'll champion this.

@platinumazure
Copy link
Member

@platinumazure platinumazure commented Nov 27, 2019

Note to merger: This should be an "Update:" as we are regarding this as an enhancement.

@kaicataldo kaicataldo changed the title Fix: improve suggestion testing experience Update: improve suggestion testing experience Dec 20, 2019
@kaicataldo kaicataldo merged commit 05faebb into eslint:master Dec 20, 2019
18 checks passed
18 checks passed
@github-actions
Verify Files
Details
@github-actions
Test (ubuntu-latest, 13.x)
Details
@github-actions
Test (ubuntu-latest, 12.x)
Details
@github-actions
Test (ubuntu-latest, 10.x)
Details
@github-actions
Test (ubuntu-latest, 8.x)
Details
@github-actions
Test (ubuntu-latest, 8.10.0)
Details
@github-actions
Test (windows-latest, 12.x)
Details
@github-actions
Test (macOS-latest, 12.x)
Details
@github-actions
Browser Test
Details
@eslint-deprecated
commit-message Commit message follows guidelines
Details
@azure-pipelines
continuous-integration Build #20191125.13 succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
@eslint-deprecated
release-monitor No patch release is pending
Details
@bradzacher bradzacher deleted the bradzacher:suggestion-tests branch Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants