Skip to content

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

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?

Activity

  1. Krinkle commented on Feb 20, 2024

    @Krinkle
    Member

    @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/.

  2. mgol commented on Feb 20, 2024

    @mgol
    MemberAuthor

    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.

  3. added this to the 3.x release milestone on Jun 20, 2024
  4. 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)[/+] on Jul 6, 2024
  5. changed the title [-]Add support for setting `module` parameter multiple times (QUnit.config.module array)[/-] [+]Support setting multiple `module` parameters (QUnit.config.module array)[/+] on Jul 6, 2024
  6. changed the title [-]Support setting multiple `module` parameters (QUnit.config.module array)[/-] [+]Support multiple `module` parameters (QUnit.config.module array)[/+] on Jul 6, 2024
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

    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