Files
moyosapp_beta.0.0.3.3_beta1/jest.setup.node.js

23 lines
827 B
JavaScript

// Node test environment setup (API route + lib tests)
// Provide missing Web APIs used by Next.js route handlers.
// Streams
try {
const webStreams = require("node:stream/web");
if (!global.TransformStream) global.TransformStream = webStreams.TransformStream;
if (!global.ReadableStream) global.ReadableStream = webStreams.ReadableStream;
if (!global.WritableStream) global.WritableStream = webStreams.WritableStream;
} catch {
// ignore
}
// Ensure fetch stack exists (Node 18+). If missing, tests will fail loudly.
// We intentionally do not polyfill via extra deps here.
if (!global.fetch || !global.Request || !global.Response || !global.Headers) {
// eslint-disable-next-line no-console
console.warn(
"[jest] Missing fetch globals (fetch/Request/Response/Headers). Node should provide these."
);
}