-
-
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
coverage.thresholds.autoUpdate
fails when defineConfig takes a function
#4695
Labels
feat: coverage
Issues and PRs related to the coverage feature
Comments
Yep, this is not supported at the moment. Only a simple use case is covered here: vitest/packages/coverage-istanbul/src/provider.ts Lines 240 to 242 in 7006bb3
We should extend the support for all common patterns like this one. But anything more complex can get tricky to resolve based on AST. |
AriPerkkio
added
bug
feat: coverage
Issues and PRs related to the coverage feature
and removed
pending triage
labels
Dec 7, 2023
Magicast doesn't support arrow functions: unjs/magicast#37. We'll need to add those first. import { parseModule } from "magicast";
const mod = parseModule(`
import { defineConfig } from "vitest/config";
export default defineConfig((config) => ({
test: {
coverage: {
enabled: true,
provider: "istanbul",
thresholds: {
autoUpdate: true,
lines: 1,
},
},
},
}));
`);
console.log(mod.exports.default.$args[0]); > file:///root/repro/node_modules/.pnpm/[email protected]/node_modules/magicast/dist/index.mjs:8529
> throw new MagicastError(`Casting "${node.type}" is not supported`, {
> ^
>
> MagicastError: Casting "ArrowFunctionExpression" is not supported
>
> 2 | import { defineConfig } from "vitest/config";
> 3 |
> 4 | export default defineConfig((config) => ({
> ^
> 5 | test: {
> 6 | coverage: {
> 7 | enabled: true,
>
> at proxify (file:///root/repro/node_modules/.pnpm/[email protected]/node_modules/magicast/dist/index.mjs:8529:13)
> at Object.get (file:///root/repro/node_modules/.pnpm/[email protected]/node_modules/magicast/dist/index.mjs:8286:18)
> at Object.get (file:///root/repro/node_modules/.pnpm/[email protected]/node_modules/magicast/dist/index.mjs:8036:26)
> at file:///root/repro/magicast-repro.mjs:20:38 |
This was referenced Jan 14, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
When using
coverage.thresholds.autoUpdate
in a config defined with a function, as shown in https://vitejs.dev/config/#conditional-config, e.g:The tests run successfully, and the coverage report is generated. However, it fails to update the coverage threshold and returns an unhandled error
MagicastError: Casting "ArrowFunctionExpression" is not supported
.If the config is defined with a simple object rather than a function, the autoUpdate behaviour works as expected.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-zwszje?file=vite.config.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: