Skip to content

Commit b14c4f7

Browse files
committed
test: review updates, explicit passed options
1 parent c623c67 commit b14c4f7

File tree

4 files changed

+572
-48
lines changed

4 files changed

+572
-48
lines changed

jest.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ export default {
3737
astTransformers: {
3838
before: [
3939
{
40-
path: 'ts-jest-mock-import-meta',
41-
options: {
42-
metaObjectReplacement: {
43-
url: 'file:///mock/import-meta-url'
44-
}
45-
}
40+
path: 'ts-jest-mock-import-meta'
4641
}
4742
]
4843
}
Lines changed: 252 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,271 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`composeTools should handle IPC errors gracefully: warn 1`] = `
3+
exports[`debugChild should attempt to highlight specific messages, access denied 1`] = `
4+
{
5+
"debug": [],
6+
"warn": [
7+
[
8+
"Error [ERR_ACCESS_DENIED]: Access denied: FileSystemRead, resource: /lorem/ipsum/dolor/sit/amet
9+
Tools Host denied fs read. In strict mode, add the resource's directory to --allow-fs-read.
10+
Optionally, you can disable strict mode entirely with pluginIsolation: 'none'.",
11+
],
12+
],
13+
}
14+
`;
15+
16+
exports[`debugChild should attempt to highlight specific messages, access denied, alt messaging 1`] = `
17+
{
18+
"debug": [],
19+
"warn": [
20+
[
21+
"Error [ERR_ACCESS_DENIED]: fs.readFileSync access is denied by permission model: FileSystemRead, resource: /lorem/ipsum/dolor/sit/amet
22+
Tools Host denied fs read. In strict mode, add the resource's directory to --allow-fs-read.
23+
Optionally, you can disable strict mode entirely with pluginIsolation: 'none'.",
24+
],
25+
[
26+
"Error [ERR_ACCESS_DENIED]: Access denied: FileSystemRead, resource: /lorem/ipsum/dolor/sit/amet
27+
Tools Host denied fs read. In strict mode, add the resource's directory to --allow-fs-read.
28+
Optionally, you can disable strict mode entirely with pluginIsolation: 'none'.",
29+
],
30+
],
31+
}
32+
`;
33+
34+
exports[`debugChild should attempt to highlight specific messages, access denied, multiple lines 1`] = `
35+
{
36+
"debug": [
37+
[
38+
"[tools-host pid=123 sid=1234567890] Error [ERR_ACCESS_DENIED]: Access denied: FileSystemRead, resource: /lorem/ipsum/dolor/sit/amet",
39+
],
40+
],
41+
"warn": [
42+
[
43+
"Error [ERR_ACCESS_DENIED]: Access denied: FileSystemRead, resource: /lorem/ipsum/dolor/sit/amet
44+
Tools Host denied fs read. In strict mode, add the resource's directory to --allow-fs-read.
45+
Optionally, you can disable strict mode entirely with pluginIsolation: 'none'.",
46+
],
47+
],
48+
}
49+
`;
50+
51+
exports[`debugChild should attempt to highlight specific messages, default 1`] = `
52+
{
53+
"debug": [
54+
[
55+
"[tools-host pid=123 sid=1234567890] lorem ipsum dolor sit amet",
56+
],
57+
],
58+
"warn": [],
59+
}
60+
`;
61+
62+
exports[`debugChild should attempt to highlight specific messages, empty string 1`] = `
63+
{
64+
"debug": [],
65+
"warn": [],
66+
}
67+
`;
68+
69+
exports[`debugChild should attempt to highlight specific messages, generic multiline error 1`] = `
70+
{
71+
"debug": [
72+
[
73+
"[tools-host pid=123 sid=1234567890] Lorem ipsum",
74+
],
75+
[
76+
"[tools-host pid=123 sid=1234567890] dolor sit",
77+
],
78+
[
79+
"[tools-host pid=123 sid=1234567890] amet",
80+
],
81+
],
82+
"warn": [],
83+
}
84+
`;
85+
86+
exports[`debugChild should attempt to highlight specific messages, generic multiline error with spaces 1`] = `
87+
{
88+
"debug": [
89+
[
90+
"[tools-host pid=123 sid=1234567890] Lorem ipsum",
91+
],
92+
[
93+
"[tools-host pid=123 sid=1234567890] dolor sit",
94+
],
95+
[
96+
"[tools-host pid=123 sid=1234567890] amet",
97+
],
98+
],
99+
"warn": [],
100+
}
101+
`;
102+
103+
exports[`debugChild should attempt to highlight specific messages, module not found 1`] = `
104+
{
105+
"debug": [],
106+
"warn": [
107+
[
108+
"Tools Host import error. Ensure external tools are ESM (no raw .ts) and resolvable.
109+
For local files, prefer a file:// URL.",
110+
],
111+
],
112+
}
113+
`;
114+
115+
exports[`debugChild should attempt to highlight specific messages, module not found, multiple lines 1`] = `
116+
{
117+
"debug": [
118+
[
119+
"[tools-host pid=123 sid=1234567890] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lorem/ipsum/dolor/sit/amet' imported from /test/path",
120+
],
121+
],
122+
"warn": [
123+
[
124+
"Tools Host import error. Ensure external tools are ESM (no raw .ts) and resolvable.
125+
For local files, prefer a file:// URL.",
126+
],
127+
],
128+
}
129+
`;
130+
131+
exports[`getFilePackageToolModules, should return filtered tool modules 1`] = `
132+
[
133+
"@scope/pkg",
134+
"file:///test/module.js",
135+
"http://example.com/module.js",
136+
"https://example.com/module.js",
137+
]
138+
`;
139+
140+
exports[`logWarningsErrors should log warnings and errors, with both warnings and errors 1`] = `
141+
[
142+
[
143+
"Tools load warnings (1)
144+
- Warning 1",
145+
],
146+
[
147+
"Tools load errors (1)
148+
- Error 1",
149+
],
150+
]
151+
`;
152+
153+
exports[`logWarningsErrors should log warnings and errors, with empty arrays 1`] = `[]`;
154+
155+
exports[`logWarningsErrors should log warnings and errors, with errors only 1`] = `
156+
[
157+
[
158+
"Tools load errors (2)
159+
- Error 1
160+
- Error 2",
161+
],
162+
]
163+
`;
164+
165+
exports[`logWarningsErrors should log warnings and errors, with single error 1`] = `
4166
[
5167
[
6-
"Failed to resolve file path: ./test-module.js: TypeError: {(intermediate value)}.resolve is not a function",
168+
"Tools load errors (1)
169+
- Single error",
7170
],
8171
]
9172
`;
10173

11-
exports[`composeTools should handle spawn errors gracefully: warn 1`] = `
174+
exports[`logWarningsErrors should log warnings and errors, with single warning 1`] = `
12175
[
13176
[
14-
"Failed to resolve file path: ./test-module.js: TypeError: {(intermediate value)}.resolve is not a function",
177+
"Tools load warnings (1)
178+
- Single warning",
15179
],
16180
]
17181
`;
18182

19-
exports[`composeTools should log warnings and errors from load: warn 1`] = `
183+
exports[`logWarningsErrors should log warnings and errors, with undefined warnings and errors 1`] = `[]`;
184+
185+
exports[`logWarningsErrors should log warnings and errors, with warnings only 1`] = `
20186
[
21187
[
22-
"Failed to resolve file path: ./test-module.js: TypeError: {(intermediate value)}.resolve is not a function",
188+
"Tools load warnings (2)
189+
- Warning 1
190+
- Warning 2",
23191
],
24192
]
25193
`;
194+
195+
exports[`spawnToolsHost attempt to spawn the Tools Host, with no pluginIsolation, node 24: spawn 1`] = `
196+
{
197+
"spawn": [
198+
[
199+
"/mock/path/to/toolsHost.js",
200+
],
201+
{
202+
"stdio": [
203+
"ignore",
204+
"pipe",
205+
"pipe",
206+
"ipc",
207+
],
208+
},
209+
],
210+
}
211+
`;
212+
213+
exports[`spawnToolsHost attempt to spawn the Tools Host, with strict pluginIsolation, node 22: spawn 1`] = `
214+
{
215+
"spawn": [
216+
[
217+
"--experimental-permission",
218+
"--allow-fs-read=/",
219+
"--allow-fs-read=/mock/path/to",
220+
"/mock/path/to/toolsHost.js",
221+
],
222+
{
223+
"stdio": [
224+
"ignore",
225+
"pipe",
226+
"pipe",
227+
"ipc",
228+
],
229+
},
230+
],
231+
}
232+
`;
233+
234+
exports[`spawnToolsHost attempt to spawn the Tools Host, with strict pluginIsolation, node 24: spawn 1`] = `
235+
{
236+
"spawn": [
237+
[
238+
"--permission",
239+
"--allow-fs-read=/",
240+
"--allow-fs-read=/mock/path/to",
241+
"/mock/path/to/toolsHost.js",
242+
],
243+
{
244+
"stdio": [
245+
"ignore",
246+
"pipe",
247+
"pipe",
248+
"ipc",
249+
],
250+
},
251+
],
252+
}
253+
`;
254+
255+
exports[`spawnToolsHost attempt to spawn the Tools Host, with undefined pluginIsolation, node 22: spawn 1`] = `
256+
{
257+
"spawn": [
258+
[
259+
"/mock/path/to/toolsHost.js",
260+
],
261+
{
262+
"stdio": [
263+
"ignore",
264+
"pipe",
265+
"pipe",
266+
"ipc",
267+
],
268+
},
269+
],
270+
}
271+
`;

0 commit comments

Comments
 (0)