Skip to content

For test file with syntax error, no "file" field for test:enqueue event with isolation: "none" #61565

@hamptonsmith

Description

@hamptonsmith

Version

v24.13.0

Platform

Linux ichor 6.14.0-37-generic #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

test

What steps will reproduce the bug?

Minimal reproduction repo: https://github.com/hamptonsmith/isolation-test-enqueue-file-field-mre

Create a test file with a syntax error:

import { test } from 'node:test';

test('a test!', () => {
    if true {
        // syntax error
    }
});

Run tests like:

run({
    files: ['./test-file.mjs'],
    isolation: 'none'
})

How often does it reproduce? Is there a required condition?

Consistently reproducible. See minimal reproduction repo: https://github.com/hamptonsmith/isolation-test-enqueue-file-field-mre

What is the expected behavior? Why is that the expected behavior?

According to the docs, the test:enqueue event should have a field file that contains the test filename. undefined is permitted only if "test was run through the REPL", which it was not.

What do you see instead?

test:enqueue event has no file field

Additional information

Found this when the downstream node-test-reporter library failed to produce useful error output for a syntax error in a test file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions