Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

'use strict';

require('../common');
require('../../common');

const spawn = require('child_process').spawn;

Expand Down
76 changes: 76 additions & 0 deletions test/fixtures/eval/eval_messages.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[eval]
[eval]:1
with(this){__filename}
^^^^

SyntaxError: Strict mode code may not include a with statement







Node.js *
42
42
[eval]:1
throw new Error("hello")
^

Error: hello








Node.js *
[eval]:1
throw new Error("hello")
^

Error: hello








Node.js *
100
[eval]:1
var x = 100; y = x;
^

ReferenceError: y is not defined








Node.js *

[eval]:1
var ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js *

[eval]:1
var ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js *
done
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

'use strict';

require('../common');
require('../../common');

const spawn = require('child_process').spawn;

Expand Down
89 changes: 89 additions & 0 deletions test/fixtures/eval/stdin_messages.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[stdin]
[stdin]:1
with(this){__filename}
^^^^

SyntaxError: Strict mode code may not include a with statement











Node.js *
42
42
[stdin]:1
throw new Error("hello")
^

Error: hello











Node.js *
[stdin]:1
throw new Error("hello")
^

Error: hello











Node.js *
100
[stdin]:1
let x = 100; y = x;
^

ReferenceError: y is not defined











Node.js *

[stdin]:1
let ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js *

[stdin]:1
let ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js *
done
77 changes: 0 additions & 77 deletions test/message/eval_messages.out

This file was deleted.

89 changes: 0 additions & 89 deletions test/message/stdin_messages.out

This file was deleted.

34 changes: 34 additions & 0 deletions test/parallel/test-node-output-eval.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
import { describe, it } from 'node:test';

describe('eval output', { concurrency: true }, () => {
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
.replaceAll(/\d+:\d+/g, '*:*');
}

const defaultTransform = snapshot.transform(
removeStackTraces,
normalize,
snapshot.replaceWindowsLineEndings,
snapshot.replaceWindowsPaths,
snapshot.replaceNodeVersion
);

function removeStackTraces(output) {
return output.replaceAll(/^ *at .+$/gm, '');
}

const tests = [
{ name: 'eval/eval_messages.js' },
{ name: 'eval/stdin_messages.js' },
];

for (const { name } of tests) {
it(name, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), defaultTransform);
});
}
});
Loading