-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
p1-choreDoesn't change code behavior (priority)Doesn't change code behavior (priority)
Description
Describe the bug
Calling toMatchInlineSnapshot within a loop produces invalid code:
import {test, expect} from "vitest";
test("snap", () => {
for (const str of ["foo", "bar"]) {
expect(str).toMatchInlineSnapshot();
// transforms to expect(str).toMatchInlineSnapshot(`"foo"``"bar"`);
}
});The transformed code produces a runtime error:
TypeError: "\"foo\"" is not a function
Typescript also does not like it:
src/basic.test.ts:5:39 - error TS2349: This expression is not callable.
Type 'String' has no call signatures.
8 expect(str).toMatchInlineSnapshot(`"foo"``"bar"`);
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-r8dfgp?file=src%2Fbasic.test.ts
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
p1-choreDoesn't change code behavior (priority)Doesn't change code behavior (priority)