Skip to content

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

Open
@mgol

Description

@mgol

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CoreFor module, test, hooks, and reporters.Type: EnhancementNew idea or feature request.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions