Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(rule-tester): allow to create empty tests#7467

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JoshuaKGoldberg merged 3 commits intotypescript-eslint:mainfromazat-io:feat/allow-empty-tests
Sep 3, 2023
Merged

feat(rule-tester): allow to create empty tests#7467

JoshuaKGoldberg merged 3 commits intotypescript-eslint:mainfromazat-io:feat/allow-empty-tests
Sep 3, 2023

Conversation

azat-io
Copy link
Contributor

@azat-ioazat-io commentedAug 13, 2023
edited by JoshuaKGoldberg
Loading

PR Checklist

Overview

In some cases I only need to test for valid or invalid scenarios.

For example, if I want to check that a rule for the ESLint plugin works with different code stylings. Or that a rule does not apply to a certain file extension.

Example:

ruleTester.run(`${RULE_NAME}: works consistently with an empty array or an array with one element`,rule,{valid:['[].includes(person)',"['Decim'].includes(bartender)"],invalid:[],},)

This test is currently crashing with an error:Error: No test found in suite invalid

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@azat-io!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@netlify
Copy link

netlifybot commentedAug 13, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit50adaa0
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/64f5038e23137900077a6b02
😎 Deploy Previewhttps://deploy-preview-7467--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloud
Copy link

nx-cloudbot commentedAug 13, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit50adaa0. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 40 targets

Sent with 💌 fromNxCloud.

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The code changes look nifty but let's discuss in a backing issue. The rule tester is an important part of the public API and I'm not sure we want to do this without talking it over first.

@JoshuaKGoldbergJoshuaKGoldberg added the please fill out the templatewe have the processes for good reasons 😔 labelAug 15, 2023
@azat-io
Copy link
ContributorAuthor

I would like to be able to skip valid or invalid scenarios in some tests. In some cases, such examples are simply not needed.

Some simple example:

importnoLetRulefrom'../rule/no-let'ruleTester.run(`disallow to use let`,rule,{valid:[],invalid:[`let a = 1`],},)

@azat-io
Copy link
ContributorAuthor

Issue#7481

@JoshuaKGoldbergJoshuaKGoldberg added triageWaiting for team members to take a look and removed please fill out the templatewe have the processes for good reasons 😔 labelsAug 28, 2023
@azat-io
Copy link
ContributorAuthor

azat-io commentedSep 3, 2023
edited
Loading

@JoshuaKGoldberg Could you review this PR?

This pull request is the last step to upgrade to version 6 before the big release in our ESLint plugin:azat-io/eslint-plugin-perfectionist#32

The same PR in ESLint also was merged:eslint/eslint#17475

JoshuaKGoldberg reacted with thumbs up emoji

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Changes look good, thanks for keeping on this!

Could you please add some unit tests for the new logic though? Conditionally skipping tests is a kind of behavior that's easy to trip up over time.

@JoshuaKGoldbergJoshuaKGoldberg added awaiting responseIssues waiting for a reply from the OP or another party and removed triageWaiting for team members to take a look labelsSep 3, 2023
@azat-io
Copy link
ContributorAuthor

azat-io commentedSep 3, 2023
edited
Loading

@JoshuaKGoldberg Hmm. Can you tell me the best way to do that? Since this problem occurs only when using RuleTester with Vitest. Because of this:https://github.com/vitest-dev/vitest/blob/main/packages/runner/src/run.ts#L331-L338

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commentedSep 3, 2023
edited
Loading

See the tests at the bottom ofRuleTester.test.ts in theconstructor constraints block for reference:

describe('constructor constraints',()=>{

They show runningruleTester.run('my-rule", ...) and then asserting on themockedDescribe.mock. You could add a similar block with tests roughly like:

it('does not call describe with valid if no valid tests are provided',()=>{construleTester=newRuleTester();ruleTester.run('my-rule',NOOP_RULE,{valid:[],invalid:[{code:'invalid',errors:[{messageId:'error'}],},],});expect(mockedDescribe.mock.calls)// ...

@azat-io
Copy link
ContributorAuthor

@JoshuaKGoldberg Thanks. Done.

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Awesome! I actually stumbled onto a want for this recently 😄 so it's very exciting to see it come in. Thanks as always@azat-io!

@JoshuaKGoldbergJoshuaKGoldberg removed the awaiting responseIssues waiting for a reply from the OP or another party labelSep 3, 2023
@JoshuaKGoldbergJoshuaKGoldberg merged commit654b35d intotypescript-eslint:mainSep 3, 2023
@azat-ioazat-io deleted the feat/allow-empty-tests branchSeptember 3, 2023 22:34
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsSep 11, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Enhancement: Add the ability to skip valid or invalid tests
2 participants
@azat-io@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp