镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

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
    loadersIssues and PRs related to ES module loaders.
    test_runnerIssues and PRs related to the test runner subsystem.
    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

    loadersIssues and PRs related to ES module loaders.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