Skip to content

Commit a0c4e0b

Browse files
authored
Make tests fail when they log errors (#1027)
To ensure that callback failures don't sneak through in testing. Also to ensure we aren't crowding users' consoles during normal operation.
1 parent c4eb50a commit a0c4e0b

File tree

4 files changed

+53
-19
lines changed

4 files changed

+53
-19
lines changed

package-lock.json

Lines changed: 44 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"vite": "^7.0.0",
3636
"vite-plugin-checker": "^0.11.0",
3737
"vite-plugin-dts": "^4.0.2",
38-
"vitest": "^4.0.3"
38+
"vitest": "^4.0.3",
39+
"vitest-fail-on-console": "^0.10.1"
3940
},
4041
"dependencies": {
4142
"@xmldom/xmldom": "^0.9.8",

test/setup/per-suite-setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import failOnConsole from "vitest-fail-on-console";
2+
3+
failOnConsole({
4+
shouldFailOnWarn: false,
5+
});

vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export default defineConfig({
4343
test: {
4444
include: ["{src,test}/**/*.{test,spec,example}.?(c|m)[jt]s?(x)"],
4545
exclude: ["dist"],
46-
globalSetup: "./test/setup/vitest-setup.js",
46+
globalSetup: "./test/setup/vitest-setup.ts",
47+
setupFiles: "./test/setup/per-suite-setup.ts",
4748
projects: [
4849
{
4950
extends: true,

0 commit comments

Comments
 (0)