Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { fileURLToPath } from "node:url";
import { configDefaults, coverageConfigDefaults, defineConfig } from "vitest/config";
import type { CoverageOptions } from "vitest/node";
// A `globalSetup` path resolves against the consuming project's root, never against this file.
const prepareNuxt = fileURLToPath(new URL("./setup/prepareNuxt.mjs", import.meta.url));
const consoleGuard = fileURLToPath(new URL("./setup/consoleGuard.ts", import.meta.url));
interface NodeConfigOptions {
thresholds?: CoverageOptions["thresholds"];
}
/** A project's thresholds, unless the run only collects coverage for the developer portal's page. */
export const gated = (thresholds: CoverageOptions["thresholds"]) =>
process.env.COVERAGE_THRESHOLDS === "off" ? undefined : thresholds;
const createNodeConfig = ({ thresholds }: NodeConfigOptions = {}) =>
defineConfig({
test: {
globals: false,
exclude: [...configDefaults.exclude, "dist/**/*"],
globalSetup: [prepareNuxt],
setupFiles: [consoleGuard],
coverage: {
provider: "v8",
include: [
"src/**/*.ts",
"lib/**/*.ts",
"app/**/*.ts",
"app/**/*.vue",
"server/**/*.ts",
"shared/**/*.ts",
"modules/**/*.ts",
"tools/**/*.ts",
],
exclude: [
...coverageConfigDefaults.exclude,
"dist/**/*",
".nuxt/**/*",
".report/**/*",
"coverage/**/*",
"**/*.config.ts",
"**/*.stories.ts",
],
reporter: ["text", "html", "clover", "json", "json-summary", "lcov"],
thresholds: gated(thresholds),
},
},
plugins: [],
});
export default createNodeConfig;
|