Skip to content

Commit

Permalink
Fix tests and remove logs from output (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak authored Feb 18, 2025
1 parent 53069ac commit aed054e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/server/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ describe("analyzeCache Test suite", () => {
})

it("should log the cache headers set by the server with a custom max age and s-maxage", () => {
vi.clearAllMocks()
const loggerSpy = vi.spyOn(console, "log")
const config = {
logs: {
Expand All @@ -171,6 +172,7 @@ describe("analyzeCache Test suite", () => {
const headers = new Headers()
headers.set("Cache-Control", "max-age=3600, s-maxage=600, private")
analyzeCache("test", config, headers)

expect(loggerSpy).toHaveBeenCalledTimes(2)
expect(loggerSpy).nthCalledWith(
1,
Expand Down
2 changes: 2 additions & 0 deletions test/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vi.spyOn(console, "log").mockImplementation(() => undefined)
vi.spyOn(console, "error").mockImplementation(() => undefined)
5 changes: 4 additions & 1 deletion vitest.workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineWorkspace([
globals: true,
environment: "happy-dom",
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
setupFiles: ["../../test/setup.tsx"],
setupFiles: ["../../test/setup.tsx", "../../test/console.ts"],
css: true,
root: "./src/client",
name: "react-router-devtools/client",
Expand All @@ -35,6 +35,7 @@ export default defineWorkspace([
test: {
globals: true,
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
setupFiles: ["../../test/console.ts"],
environment: "happy-dom",
root: "./src/server",
name: "react-router-devtools/server",
Expand All @@ -58,6 +59,7 @@ export default defineWorkspace([
test: {
globals: true,
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
setupFiles: ["../../test/console.ts"],
environment: "happy-dom",
root: "./src/vite",
name: "react-router-devtools/vite",
Expand All @@ -81,6 +83,7 @@ export default defineWorkspace([
test: {
globals: true,
exclude: ["**/node_modules/**", "**/dist/**", "**/docs/**", "**/public/**", "**/test-apps/**"],
setupFiles: ["../../test/console.ts"],
environment: "node",
root: "./src/shared",
name: "react-router-devtools/shared",
Expand Down

0 comments on commit aed054e

Please sign in to comment.