node/test/fixtures/test-runner/output/eval_spec.js
Colin Ihrig 3c5764a0e2
test_runner: handle undefined test locations
This commit updates the built in reporters to check for the
documented case of a test's location being undefined.

As a drive by fix, the C++ code for computing the test location
now returns undefined if the script location is empty. This lets
tests run inside of eval().

PR-URL: https://github.com/nodejs/node/pull/52036
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2024-03-12 18:16:28 +00:00

10 lines
175 B
JavaScript

// Flags: --test-reporter=spec
'use strict';
eval(`
const { test } = require('node:test');
test('passes');
test('fails', () => {
throw new Error('fail');
});
`);