Skip to content

Commit

Permalink
test: allow win32 line endings, path displays
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 7, 2023
1 parent ed07dd9 commit 3fd7b4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/test/esm-loader.spec.ts
Expand Up @@ -58,7 +58,7 @@ test.suite('esm', (test) => {
// also, node 20 puts the type in here when source mapping it, so it
// shows as Foo.Foo.bar
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar \(/m);
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar ([^\n]+[\\\/]throw( |%20)error\.ts:100:17)`/m);
expect(r.err!.message).toMatch(/^ at (Foo\.){1,2}bar ([^\n\)]+[\\\/]throw( |%20)error\.ts:100:17)/m);
});

test.suite('supports experimental-specifier-resolution=node', (test) => {
Expand Down
12 changes: 9 additions & 3 deletions src/test/index.spec.ts
Expand Up @@ -181,7 +181,9 @@ test.suite('ts-node', (test) => {
throw new Error('Command was expected to fail, but it succeeded.');
}

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

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

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

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

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

for (const flavor of [
Expand Down
2 changes: 1 addition & 1 deletion src/test/register.spec.ts
Expand Up @@ -109,7 +109,7 @@ test.suite('register(create(options))', (test) => {
} catch (error: any) {
// on windows in node 20, this is printed as a quasi-url, like
// d:/path/to/throw%20error.ts
exp(error.stack).toMatch(/Error: this is a demo\n at Foo\.bar \([^)]+[\\\/]throw( %20)error\.ts:100:17\)\n/);
exp(error.stack).toMatch(/Error: this is a demo\n at Foo\.bar \([^)]+[\\\/]throw( |%20)error\.ts:100:17\)\n/);
}
});

Expand Down

0 comments on commit 3fd7b4f

Please sign in to comment.