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

fix(vitest/require-local-test-context-for-concurrent-snapshots): report for all types of snapshot tests #322

Conversation

Haberkamp
Copy link
Contributor

What?

The rule now reports any invalid snapshot assertion in concurrent tests. That is when they don't use the local Test Context

Why?

It's required to use the local Test Context for every single type of snapshot tests.

How?

I expanded the criteria for what is a snapshot assertion and what is not.

Testing?

Run the unit tests to verify the new expected result. Follow these steps if you want to test it on your local machine:

Activate the rule vitest/require-local-test-context-for-all-types-of-snapshot-tests

Copy the code snippet below

import { describe, expect } from 'vitest';

describe.concurrent("something", () => {
  it("something", () => {
    expect(() => {
      throw new Error('foo')
    }).toThrowErrorMatchingInlineSnapshot();
  });

  it("something", () => {
    expect("foo").toMatchFileSnapshot("./bar.txt");
  });
});

it("something", () => {
  expect(() => {
    throw new Error("foo");
  }).toThrowErrorMatchingSnapshot();
});

You will see that rule reported in three places.

Copy link
Owner

@veritem veritem left a comment

Choose a reason for hiding this comment

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

LGTM!!

@veritem veritem merged commit efaf109 into veritem:main Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants