Skip to content

Commit

Permalink
chore: Moving Jest setup to JSDOM for the firefly-honeycomb project
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance authored Jan 20, 2025
1 parent 811f20d commit 5094cbf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/firefly-honeycomb/jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://github.com/mswjs/msw/issues/1796

import { TextDecoder, TextEncoder } from "node:util";

global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
5 changes: 4 additions & 1 deletion packages/firefly-honeycomb/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import type { Config } from "jest";
import { swcConfig } from "./swc.jest.ts";

const config: Config = {
testRegex: "/tests/*/.*\\.test\\.(ts|tsx)$",
// JSDOM is required for OTel instrumentation like "@opentelemetry/instrumentation-document-load".
testEnvironment: "jsdom",
testRegex: "/tests/*/.*\\.test\\.ts$",
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transformIgnorePatterns: [
"node_modules/(?!.pnpm|memoize|mimic-function|@workleap/honeycomb)"
],
transform: {
"^.+\\.(js|ts|tsx)$": ["@swc/jest", swcConfig as Record<string, unknown>]
},
setupFilesAfterEnv: ["<rootDir>/jest-setup.js"],
cacheDirectory: "./node_modules/.cache/jest",
verbose: true
};
Expand Down
1 change: 1 addition & 0 deletions packages/firefly-honeycomb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@workleap/typescript-configs": "3.0.2",
"eslint": "8.57.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"ts-node": "10.9.2",
"typescript": "5.5.4"
},
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5094cbf

Please sign in to comment.