Skip to content

Commit 052a612

Browse files
committed
fix: msw 활성화 환경 변수 추가 및 스크립트 추가
1 parent 85e0ab1 commit 052a612

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7+
"dev:msw": "MOCKING_ENABLED=true next dev",
78
"build": "next build",
89
"start": "next start",
910
"lint": "next lint",

src/app/layout.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export const metadata: Metadata = {
1313
description: "Generated by create next app",
1414
};
1515

16-
if (process.env.NEXT_RUNTIME === "nodejs") {
16+
if (
17+
process.env.NEXT_RUNTIME === "nodejs" &&
18+
process.env.MOCKING_ENABLED === "true"
19+
) {
1720
const { server } = await import("@/mocks/server");
1821
console.info("🔥 [MSW] Server-side mocking enabled");
1922
server.listen();

src/providers/MSWProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Suspense, use } from "react";
55
import { handlers } from "@/mocks/handlers";
66

77
const mockingEnabledPromise =
8-
typeof window !== "undefined"
8+
typeof window !== "undefined" && process.env.MOCKING_ENABLED === "true"
99
? import("@/mocks/browser").then(async ({ worker }) => {
1010
await worker.start({
1111
onUnhandledRequest(request, print) {

0 commit comments

Comments
 (0)