Skip to content

test runner does not pass cli flags to test files when running --test #43941

Closed

Description

@MoLow

for example, running node --loader ts-node/esm --test a.test.ts will fail:

/// a.test.ts

import { test } from 'node:test'

test(async () => {
	const a: any = {};
});

the challenge is that each test file spawns a new process

Activity

  1. added
    loaders
    test_runner
    on Jul 22, 2022
  2. MoLow commented on Jul 22, 2022

    @MoLow
    MemberAuthor

    this is obviously the case for any other node flag

  3. aduh95 commented on Jul 23, 2022

    @aduh95
    Contributor

    A workaround is to use NODE_OPTIONS env variable (NODE_OPTIONS="--loader ts-node/esm" node --test a.test.ts). It would still be worth to find a better way to integrate loaders though.

  4. changed the title [-]test runner does not support ESM loaders[/-] [+]test runner does not pass cli flags to test files when running `--test`[/+] on Jul 24, 2022
  5. aduh95 commented on Jul 26, 2022

    @aduh95
    Contributor

    Related: #43973

  6. MoLow commented on Aug 5, 2022

    @MoLow
    MemberAuthor

    I am not sure what I did wrong on the first time I tested this, but I re-tested it and it does actually work.
    see https://github.com/nodejs/node/blob/main/lib/internal/main/test_runner.js#L100-L102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    loaderstest_runner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions