-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjest.config.browser.ts
More file actions
66 lines (57 loc) · 1.76 KB
/
jest.config.browser.ts
File metadata and controls
66 lines (57 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* eslint-disable */
/**
* Browser Environment Jest Configuration
*
* Purpose: Test SDK in browser-like environment (jsdom) to catch Node.js-only API usage
* This configuration will FAIL if code tries to use: fs, path, crypto, etc.
*/
export default {
displayName: "browser-environment",
// ⚠️ CRITICAL: Use jsdom (browser) instead of node environment
testEnvironment: "jest-environment-jsdom",
// Only run browser-specific tests
testMatch: ["**/test/browser/**/*.spec.ts"],
transform: {
"^.+\\.[tj]s$": [
"ts-jest",
{
tsconfig: {
// Browser-only libs
lib: ["dom", "dom.iterable", "es2020"],
// Include jest types for test files
types: ["jest", "@types/node"],
target: "es2020",
module: "commonjs",
esModuleInterop: true,
skipLibCheck: true
},
diagnostics: {
warnOnly: true
}
},
],
},
moduleFileExtensions: ["ts", "js", "html"],
// Browser globals (available in jsdom)
setupFilesAfterEnv: ['<rootDir>/jest.setup.browser.ts'],
// Collect coverage separately for browser tests
collectCoverage: true,
coverageDirectory: "./reports/browser-environment/coverage/",
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.spec.ts", "!src/index.ts"],
// Timeout for browser environment tests
testTimeout: 10000,
// Don't mock Node.js modules globally - let natural browser environment catch issues
// moduleNameMapper: {},
reporters: [
"default",
[
"jest-html-reporter",
{
pageTitle: "Browser Environment Test Report",
outputPath: "reports/browser-environment/index.html",
includeFailureMsg: true,
includeConsoleLog: true,
},
],
],
};