Skip to content

[Feature Request]: Option to run tests in parallel? #1777

Open
@NullVoxPopuli

Description

I would be great if I could declare a module as parallel, like this:

import { module, test } from 'qunit';

module.parallel('my suite', function (hooks) {
  // all 3 of these tests run "at the same time"
  test('a', async function (assert) {
    await 0;
    assert.ok(true);
  });

  test('b', async function (assert) {
    await 0;
    assert.ok(true);
  });

  test('c', async function (assert) {
    await 0;
    assert.ok(true);
  });
});

these tests are overly simplified, but I imagine this could lead to implementation of:

// psuedo code
if (module.isParallel) {
  await Promise.all(module.tests.map(test => runTest(test)));
} else {
  // current behavior
  for (let test of module.tests) {
    await runTest(test);
  }
}

this could greatly improve the performance of async tests that may be I/O bound (and thus await-ing on external things to happen)


maybe this should be module.concurrent, since you can't actually have single-threaded parallelism.

to have parallelism, you'd need to split test-running in to workers -- which would be useful as well -- and maybe easier from a context isolation perspective?

Metadata

Assignees

No one assigned

    Labels

    Component: CoreFor module, test, hooks, and reporters.Type: EnhancementNew idea or feature request.Type: MetaSeek input from maintainers and contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions