Skip to content

Introduce data providers to QUnit #1568

@ventuno

Description

@ventuno

Many test frameworks offer ways to avoid test duplication by allowing parameters to be passed into a test. For example, Jest offers test.each:

test.each([
  [1, 1, 2],
  [1, 2, 3],
  [2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
  expect(a + b).toBe(expected);
});

TestNG (a Java test framework) offers the DataProviders which use decorators to attach data sources to tests.

It makes sense for QUnit to offer the same feature.

Sample implementation

#1569

Open questions

  1. Jest offers the possibility of customizing the test name by providing printf-like parameters (using Node's util.format);
  2. Jest also offers a describe.each. I personally the benefit of this feature, but we should consider implementing our version of module.each.

Metadata

Metadata

Assignees

Labels

Category: APIComponent: 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

Relationships

None yet

Development

No branches or pull requests

Issue actions