Skip to content

Commit 3fd7b4f

Browse files
committed
test: allow win32 line endings, path displays
1 parent ed07dd9 commit 3fd7b4f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/test/esm-loader.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test.suite('esm', (test) => {
5858
// also, node 20 puts the type in here when source mapping it, so it
5959
// shows as Foo.Foo.bar
6060
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar \(/m);
61-
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar ([^\n]+[\\\/]throw( |%20)error\.ts:100:17)`/m);
61+
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar ([^\n\)]+[\\\/]throw( |%20)error\.ts:100:17)/m);
6262
});
6363

6464
test.suite('supports experimental-specifier-resolution=node', (test) => {

src/test/index.spec.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ test.suite('ts-node', (test) => {
181181
throw new Error('Command was expected to fail, but it succeeded.');
182182
}
183183

184-
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/);
184+
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(
185+
/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/
186+
);
185187
});
186188

187189
test('should work with source maps in --transpile-only mode', async () => {
@@ -190,7 +192,9 @@ test.suite('ts-node', (test) => {
190192
throw new Error('Command was expected to fail, but it succeeded.');
191193
}
192194

193-
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/);
195+
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(
196+
/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/
197+
);
194198
});
195199

196200
test('eval should work with source maps', async () => {
@@ -199,7 +203,9 @@ test.suite('ts-node', (test) => {
199203
throw new Error('Command was expected to fail, but it succeeded.');
200204
}
201205

202-
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/);
206+
expect(r.err.message.replace(/\r\n/g, '\n')).toMatch(
207+
/throw( |%20)error\.ts:100\n bar\(\) \{ throw new Error\('this is a demo'\); \}/
208+
);
203209
});
204210

205211
for (const flavor of [

src/test/register.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test.suite('register(create(options))', (test) => {
109109
} catch (error: any) {
110110
// on windows in node 20, this is printed as a quasi-url, like
111111
// d:/path/to/throw%20error.ts
112-
exp(error.stack).toMatch(/Error: this is a demo\n at Foo\.bar \([^)]+[\\\/]throw( %20)error\.ts:100:17\)\n/);
112+
exp(error.stack).toMatch(/Error: this is a demo\n at Foo\.bar \([^)]+[\\\/]throw( |%20)error\.ts:100:17\)\n/);
113113
}
114114
});
115115

0 commit comments

Comments
 (0)