Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support multiple module parameters (QUnit.config.module array) #1742

Open
mgol opened this issue Feb 20, 2024 · 2 comments
Open

Support multiple module parameters (QUnit.config.module array) #1742

mgol opened this issue Feb 20, 2024 · 2 comments
Labels
Component: Core For module, test, hooks, and reporters. Type: Enhancement New idea or feature request.
Milestone

Comments

@mgol
Copy link
Member

mgol commented Feb 20, 2024

Tell us about your runtime:

  • QUnit version: 2.20.1
  • Which environment are you using? (e.g., browser, Node): browser
  • How are you running QUnit? (e.g., QUnit CLI, Grunt, Karma, manually in browser): manually in browser: currently in Chrome 121.0.6167.184 for macOS or Firefox 123.0 for macOS

What are you trying to do?

I'm trying to run tests for multiple modules by providing a URL directly, without initial UI interactions on my side.

Code that reproduces the problem:

In jQuery, we have multiple test modules. It is possible to choose them from the module dropdown which results in multiple moduleId added to the URL. But you cannot compute those moduleIds in your mind easily since they are hashed.

QUnit supports specifying a module via the module query parameter. In jQuery, we often use it to run tests divided by module on TestSwarm in CI.

I'd like to pass multiple modules via specifying the module field directly multiple times. Example: ?module=support&module=basic.

What did you expect to happen?

I expected ?module=support&module=basic to run all the tests from the support & basic modules.

What actually happened?

Passing the module parameter multiple times results in errors. If you e.g. pass ?module=support&module=basic, you get an error:

qunit.js:3041 Uncaught TypeError: config.module.toLowerCase is not a function
    at Test.valid (qunit.js:3041:59)
    at new Test (qunit.js:2428:19)
    at addTest (qunit.js:3116:19)
    at Object.test (qunit.js:3133:5)
    at ready.js:13:8
    at ready.js:166:4

The error happens in the following line:

const selectedModule = config.module && config.module.toLowerCase();
.

It happens because while in the ?module=support case config.module is "support", in the ?module=support&module=basic case it's an array: ["support", "basic"].

I think this way of passing multiple modules worked in the past. Can we bring it back?

@Krinkle
Copy link
Member

Krinkle commented Feb 20, 2024

@mgol I'll look into if/when this worked. I'd certainly welcome it as a new feature, even if it wasn't there before.

Today, one way to run multiple modules in the HTML Runner, is to select them from the dropdown menu. Internally, this is powered by the moduleId parameter. For example: ?moduleId=c7776548&moduleId=52aa3c97.

To apply a free-form filter by word match, you can use also use filter with a value like support or /support|basic/.

@mgol
Copy link
Member Author

mgol commented Feb 20, 2024

filter is a nice workaround but it also catches test titles from other modules.

I know about the moduleId way but this is not that useful when you want to schedule a specific run from the command line. @timmywil is just hitting it which made him copy the QUnit hashing algorithm so that running tests in multiple modules from the CLI are possible. It'd be much easier if we could just pass multiple module names.

@Krinkle Krinkle added Component: HTML Reporter Type: Enhancement New idea or feature request. labels Mar 3, 2024
@Krinkle Krinkle added this to the 3.x release milestone Jun 20, 2024
@Krinkle Krinkle changed the title Not possible to run multiple modules by passing the module parameter multiple times Add support for setting module parameter multiple times (QUnit.config.module array) Jul 6, 2024
@Krinkle Krinkle added Component: Core For module, test, hooks, and reporters. and removed Component: HTML Reporter labels Jul 6, 2024
@Krinkle Krinkle changed the title Add support for setting module parameter multiple times (QUnit.config.module array) Support setting multiple module parameters (QUnit.config.module array) Jul 6, 2024
@Krinkle Krinkle changed the title Support setting multiple module parameters (QUnit.config.module array) Support multiple module parameters (QUnit.config.module array) Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core For module, test, hooks, and reporters. Type: Enhancement New idea or feature request.
Development

No branches or pull requests

2 participants