Skip to content

test runner global configuration #43895

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
MoLow opened this issue Jul 18, 2022 · 7 comments
Closed

test runner global configuration #43895

MoLow opened this issue Jul 18, 2022 · 7 comments
Labels
discuss Issues opened for discussions and feedbacks. test_runner Issues and PRs related to the test runner subsystem.

Comments

@MoLow
Copy link
Member

MoLow commented Jul 18, 2022

the question of global configuration for the test runner was raised on a few places,

I think it is worth a small discussion about how to provide the ability to globaly configure the test runner.

a few things that might have already been noted in the above links:

  • adding many cli flags dedicated for the test might be hard to maintain
  • test runner potentially runs in multiple processes so propagation of the global configuration needs to be considered
@MoLow MoLow added discuss Issues opened for discussions and feedbacks. test_runner Issues and PRs related to the test runner subsystem. labels Jul 18, 2022
@MoLow
Copy link
Member Author

MoLow commented Jul 18, 2022

@nodejs/test_runner
@benjamingr

@MoLow
Copy link
Member Author

MoLow commented Jul 18, 2022

my personal thoughts:
It is preferable for global configuration to be a js file so it can contain js functions/objects (i.e for some of the use cases above such as reporters)
one option is one single --test-config="file.js" flag to cover all configurations
another option is looking for a .testrc file

@MoLow MoLow changed the title test_runner: global configuration test runner global configuration Jul 18, 2022
@aduh95
Copy link
Contributor

aduh95 commented Jul 19, 2022

FWIW @nodejs/loaders is also brainstorming how to make configuration a thing in nodejs/loaders#98 (comment), maybe we can find a solution that works for both.

@Jamesernator
Copy link

Specifying test files would be helpful too, at current the CLI shell expansions can be a bit limiting, for example using node --loader ts-node/esm --test **/*.test.ts will accidentally include files inside node_modules/. Being able to specify a test config with inclusions/exclusions would be considerably more helpful.

A couple bikesheds:

// maybe npm "files" like
export default {
    loader: "ts-node/esm",
    files: [
        "**/*.test.ts",
        "!node_modules/",
    ],
}

// maybe tsconfig like
export default {
   loader: "ts-node/esm",
   include: [
       "**/*.test.ts",
   ],
   exclude: [
       "node_modules/",
   ],
}

@JakobJingleheimer
Copy link
Member

I would expect the files to live in a specific directory like ./src, in which case, couldn't you do node --loader ts-node/esm --test ./src/**/*.test.ts

@Jamesernator
Copy link

I would expect the files to live in a specific directory like ./src

It's a common pattern, but not one I often use for multiple reasons.

@MoLow
Copy link
Member Author

MoLow commented Aug 24, 2022

Specifying test files can now be done using #44241,
closing this as this solves most of the use cases in this issue

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
discuss Issues opened for discussions and feedbacks. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants