-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
toMatchInlineSnapshot
produces invalid code when called inside a loop
#6327
Comments
toMatchInlineSnapshot
produces invalid typescript when called inside a looptoMatchInlineSnapshot
produces invalid code when called inside a loop
|
I guess we can try to find a way to throw an error here for a better DX, but I don't have ideas how. I will keep the issue open for now. |
I remembered Jest throws a better error for this case. I haven't checked how they do, but made a quick repro for a reference https://stackblitz.com/edit/github-tj5mf5?file=basic.test.js
|
Could it be supported, though? It should be possible to encode multiple values in one string, but likely it will need some creative escaping to support all possible values. |
I don't think it could be supported or should be supported. It is much harder to support internally and it makes the result code look even less readable. Use |
Describe the bug
Calling
toMatchInlineSnapshot
within a loop produces invalid code:The transformed code produces a runtime error:
Typescript also does not like it:
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-r8dfgp?file=src%2Fbasic.test.ts
Validations
The text was updated successfully, but these errors were encountered: