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

Enhancement: Add the ability to skip valid or invalid tests #7481

Closed
4 tasks done
azat-io opened this issue Aug 15, 2023 · 6 comments · Fixed by #7467
Closed
4 tasks done

Enhancement: Add the ability to skip valid or invalid tests #7481

azat-io opened this issue Aug 15, 2023 · 6 comments · Fixed by #7467
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: rule-tester Issues related to the @typescript-eslint/rule-tester package

Comments

@azat-io
Copy link
Contributor

azat-io commented Aug 15, 2023

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

rule-tester

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

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

Fail

import noLetRule from '../rule/no-let'

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

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

@azat-io azat-io added enhancement New feature or request triage Waiting for maintainers to take a look labels Aug 15, 2023
@azat-io azat-io changed the title Enhancement: <a short description of my proposal> Enhancement: allow to create empty tests Aug 15, 2023
@azat-io azat-io changed the title Enhancement: allow to create empty tests Enhancement: Add the ability to skip valid or invalid tests Aug 15, 2023
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Aug 17, 2023

Looking through https://eslint.org/docs/latest/integrate/nodejs-api, it looks like the core ESLint RuleTester does support valid: []. And when I try it out locally, it passes with 0 passing.

In fact, ours does too! At least with Mocha. Repro here: https://github.com/JoshuaKGoldberg/repros/tree/eslint-rule-tester-empty-arrays

npx mocha *.test.js

0 passing

So I'm betting it's your specific test runner that's giving you grief. Both the core RuleTester and our version are pretty thin wrappers over test runner APIs.

To accept this issue, I think we'd want to see a reproduction that shows where the core ESLint RuleTester supports something we don't. I.e. a case where you can run with valid: [] in them but not us.

@JoshuaKGoldberg JoshuaKGoldberg added unable to repro issues that a maintainer was not able to reproduce external This issue is with another package, not typescript-eslint itself package: rule-tester Issues related to the @typescript-eslint/rule-tester package and removed triage Waiting for maintainers to take a look enhancement New feature or request labels Aug 17, 2023
@bradzacher
Copy link
Member

Yeah I wouldn't want us to break from eslint here - the intent with RuleTester is to keep it as close to core as possible - just adding new features (eg dependency filtering and snapshot testing) rather than changing the internal logic.

I believe that the logic I used was exactly the same as the underlying RuleTester.
So I'd agree that if this doesn't work upstream, then we'd want to fix it upstream first so that the two remain aligned.

@JoshuaKGoldberg
Copy link
Member

Maybe relevant: eslint/eslint#17455

@snitin315
Copy link

We have accepted this as an enhancement in ESLint and it will be implemented soon.

@JoshuaKGoldberg
Copy link
Member

Great, thanks! Once the ESLint PR is approved we can take one in here. Just making sure our implementation doesn't differ too much.

Ref: eslint/eslint#17455 -> eslint/eslint#17475

@JoshuaKGoldberg JoshuaKGoldberg added blocked by external API Blocked by a tool we depend on exposing an API, such as TypeScript's Type Relationship API enhancement New feature or request and removed external This issue is with another package, not typescript-eslint itself unable to repro issues that a maintainer was not able to reproduce labels Aug 19, 2023
@azat-io
Copy link
Contributor Author

azat-io commented Aug 27, 2023

Looks like this PR was merged: eslint/eslint#17475

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed blocked by external API Blocked by a tool we depend on exposing an API, such as TypeScript's Type Relationship API labels Sep 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: rule-tester Issues related to the @typescript-eslint/rule-tester package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants