Skip to content

Commit aed054e

Browse files
authored
Fix tests and remove logs from output (#196)
1 parent 53069ac commit aed054e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/server/utils.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ describe("analyzeCache Test suite", () => {
161161
})
162162

163163
it("should log the cache headers set by the server with a custom max age and s-maxage", () => {
164+
vi.clearAllMocks()
164165
const loggerSpy = vi.spyOn(console, "log")
165166
const config = {
166167
logs: {
@@ -171,6 +172,7 @@ describe("analyzeCache Test suite", () => {
171172
const headers = new Headers()
172173
headers.set("Cache-Control", "max-age=3600, s-maxage=600, private")
173174
analyzeCache("test", config, headers)
175+
174176
expect(loggerSpy).toHaveBeenCalledTimes(2)
175177
expect(loggerSpy).nthCalledWith(
176178
1,

test/console.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vi.spyOn(console, "log").mockImplementation(() => undefined)
2+
vi.spyOn(console, "error").mockImplementation(() => undefined)

vitest.workspace.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineWorkspace([
1111
globals: true,
1212
environment: "happy-dom",
1313
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
14-
setupFiles: ["../../test/setup.tsx"],
14+
setupFiles: ["../../test/setup.tsx", "../../test/console.ts"],
1515
css: true,
1616
root: "./src/client",
1717
name: "react-router-devtools/client",
@@ -35,6 +35,7 @@ export default defineWorkspace([
3535
test: {
3636
globals: true,
3737
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
38+
setupFiles: ["../../test/console.ts"],
3839
environment: "happy-dom",
3940
root: "./src/server",
4041
name: "react-router-devtools/server",
@@ -58,6 +59,7 @@ export default defineWorkspace([
5859
test: {
5960
globals: true,
6061
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
62+
setupFiles: ["../../test/console.ts"],
6163
environment: "happy-dom",
6264
root: "./src/vite",
6365
name: "react-router-devtools/vite",
@@ -81,6 +83,7 @@ export default defineWorkspace([
8183
test: {
8284
globals: true,
8385
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
86+
setupFiles: ["../../test/console.ts"],
8487
environment: "node",
8588
root: "./src/shared",
8689
name: "react-router-devtools/shared",

0 commit comments

Comments
 (0)