Skip to content

Commit f9e7cc4

Browse files
test: add ts eval snapshots
1 parent 2e368d0 commit f9e7cc4

File tree

4 files changed

+80
-8
lines changed

4 files changed

+80
-8
lines changed

test/fixtures/eval/eval_messages.snapshot

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ with(this){__filename}
88
: ^^^^
99
`----
1010

11-
1211
Caused by:
1312
failed to parse
1413

1514
SyntaxError: Strict mode code may not include a with statement
1615

17-
18-
19-
20-
2116
Node.js *
2217
42
2318
42

test/fixtures/eval/eval_typescript.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
require('../../common');
4+
5+
const spawnSync = require('child_process').spawnSync;
6+
7+
const queue = [
8+
'enum Foo{};',
9+
'throw new SyntaxError("hello")',
10+
'const foo;',
11+
'let x: number = 100;x;',
12+
'const foo: string = 10;',
13+
'function foo(){};foo<Number>(1);',
14+
'interface Foo{};const foo;',
15+
'function foo(){ await Promise.resolve(1)};',
16+
];
17+
18+
for (const cmd of queue) {
19+
const args = ['--disable-warning=ExperimentalWarning', '-p', cmd];
20+
const result = spawnSync(process.execPath, args, {
21+
stdio: 'pipe'
22+
});
23+
process.stdout.write(result.stdout);
24+
process.stdout.write(result.stderr);
25+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[eval]:1
2+
enum Foo{};
3+
^^^^
4+
x TypeScript enum is not supported in strip-only mode
5+
,----
6+
1 | enum Foo{};
7+
: ^^^^^^^^^^
8+
`----
9+
10+
SyntaxError: Unexpected reserved word
11+
12+
Node.js *
13+
[eval]:1
14+
throw new SyntaxError("hello")
15+
^
16+
17+
SyntaxError: hello
18+
19+
Node.js *
20+
[eval]:1
21+
const foo;
22+
^^^
23+
24+
SyntaxError: Missing initializer in const declaration
25+
26+
Node.js *
27+
100
28+
undefined
29+
false
30+
[eval]:1
31+
;const foo;
32+
^^^
33+
34+
SyntaxError: Missing initializer in const declaration
35+
36+
Node.js *
37+
[eval]:1
38+
function foo(){ await Promise.resolve(1)};
39+
^^^^^
40+
x await isn't allowed in non-async function
41+
,----
42+
1 | function foo(){ await Promise.resolve(1)};
43+
: ^^^^^^^
44+
`----
45+
46+
Caused by:
47+
failed to parse
48+
49+
SyntaxError: await is only valid in async functions and the top level bodies of modules
50+
51+
Node.js *

test/parallel/test-node-output-eval.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ describe('eval output', { concurrency: true }, () => {
1010
}
1111

1212
const defaultTransform = snapshot.transform(
13-
removeStackTraces,
14-
filterEmptyLines,
1513
normalize,
1614
snapshot.replaceWindowsLineEndings,
1715
snapshot.replaceWindowsPaths,
18-
snapshot.replaceNodeVersion
16+
snapshot.replaceNodeVersion,
17+
removeStackTraces,
18+
filterEmptyLines,
1919
);
2020

2121
function removeStackTraces(output) {
@@ -29,6 +29,7 @@ describe('eval output', { concurrency: true }, () => {
2929
const tests = [
3030
{ name: 'eval/eval_messages.js' },
3131
{ name: 'eval/stdin_messages.js' },
32+
{ name: 'eval/eval_typescript.js' },
3233
];
3334

3435
for (const { name } of tests) {

0 commit comments

Comments
 (0)