-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Option to turn off strict mode #2198
Comments
Your code is treated as ESM. You cannot disable strict mode in ESM. |
What do you think about having alternative options to include setupFiles? |
What do you mean? |
Copy the setup files code on top of the test files without it being a module. |
Test files are also treated as modules. Every file is treated as a module |
@sheremet-va I guess what I'm asking is how difficult would it be to have an option to not do that? For example karma puts setup files in <script> tags. But karma is very slow. Or maybe it's easier to copy the contents of setup files to into the same module as the test file? I feel like this should definitely be possible. |
Yes please. want this. I had to patch my client.mjs: - const codeDefinition = `'use strict';async (${Object.keys(context).join(",")})=>{{`;
+ const codeDefinition = `async (${Object.keys(context).join(",")})=>{{`; |
Vitest runs code in strict mode by default because it assumes the file follows ESM spec. We won't add an escape hatch for non-strict mode because we don't support CJS tests. |
Clear and concise description of the problem
Currently, strict mode is forced on instead of being an option, making it not usable for certain types of codebases.
Suggested solution
config toggle to turn off strict mode.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: