@vyriy/jest-config 0.8.12 → 0.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,6 +70,8 @@ Jest transformer, reporter, environment, and style proxy packages are resolved f
70
70
 
71
71
  The transform ignore rules keep normal dependencies ignored but allow Vyriy packages and the ESM Markdown/unified ecosystem used by SSG and docs packages to pass through SWC.
72
72
 
73
+ JSDOM uses Node export conditions in this shared config so server-oriented packages, including the AWS SDK, resolve their Node builds during tests. A small setup file also provides Node's `TextEncoder` and `TextDecoder` globals for dependencies that expect them at import time.
74
+
73
75
  ## Install
74
76
 
75
77
  With npm:
package/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { createRequire } from 'node:module';
2
+ import { extname } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
2
4
  const requireFromPackage = createRequire(import.meta.url);
3
5
  const resolveDependency = (request) => requireFromPackage.resolve(request);
6
+ const packageModuleExtension = extname(fileURLToPath(import.meta.url));
7
+ const resolvePackageFile = (path) => fileURLToPath(new URL(path, import.meta.url));
4
8
  const transformEsmPackages = [
5
9
  '@vyriy',
6
10
  'bail',
@@ -115,7 +119,14 @@ const config = {
115
119
  ],
116
120
  resetMocks: false,
117
121
  restoreMocks: true,
122
+ setupFiles: [resolvePackageFile(`./setup${packageModuleExtension}`)],
118
123
  testEnvironment: resolveDependency('jest-environment-jsdom'),
124
+ testEnvironmentOptions: {
125
+ customExportConditions: [
126
+ 'node',
127
+ 'node-addons',
128
+ ],
129
+ },
119
130
  testMatch: ['**/?(*.)+(spec|test).?([mc])[jt]s?(x)'],
120
131
  testPathIgnorePatterns: [
121
132
  '/node_modules/',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyriy/jest-config",
3
- "version": "0.8.12",
3
+ "version": "0.8.13",
4
4
  "description": "Shared Jest config for Vyriy projects",
5
5
  "homepage": "https://vyriy.dev/docs/jest/",
6
6
  "type": "module",
@@ -38,6 +38,16 @@
38
38
  "types": "./index.d.ts",
39
39
  "import": "./index.js",
40
40
  "default": "./index.js"
41
+ },
42
+ "./setup": {
43
+ "types": "./setup.d.ts",
44
+ "import": "./setup.js",
45
+ "default": "./setup.js"
46
+ },
47
+ "./setup.js": {
48
+ "types": "./setup.d.ts",
49
+ "import": "./setup.js",
50
+ "default": "./setup.js"
41
51
  }
42
52
  }
43
53
  }
package/setup.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/setup.js ADDED
@@ -0,0 +1,15 @@
1
+ import { TextDecoder, TextEncoder } from 'node:util';
2
+ if (!globalThis.TextDecoder) {
3
+ Object.defineProperty(globalThis, 'TextDecoder', {
4
+ configurable: true,
5
+ value: TextDecoder,
6
+ writable: true,
7
+ });
8
+ }
9
+ if (!globalThis.TextEncoder) {
10
+ Object.defineProperty(globalThis, 'TextEncoder', {
11
+ configurable: true,
12
+ value: TextEncoder,
13
+ writable: true,
14
+ });
15
+ }