我需要一种获取所有余烬测试名称的方法,因为我想使用--filter“ TEST-NAME”标志在单独的线程中运行它们。
现在,我正在使用硬编码数组。
答案 0 :(得分:0)
它没有记录,但是您可以使用根config
对象上的QUnit
对象来获取测试套件中的所有模块,然后获取每个模块中的测试及其名称。请注意,模块中的所有 not 测试仍会出现,但模块名称为空。这是runnable jsfiddle with the example,然后是下面的代码。
QUnit.test('no-module', (assert) => { assert.equal(0,0) })
QUnit.module('foobar', () => {
QUnit.test('foo', (assert) => { assert.equal(1, 1) })
QUnit.test('bar', (assert) => { assert.equal(2, 2) })
})
QUnit.module('batbaz', () => {
QUnit.test('bat', (assert) => { assert.equal(3, 3) })
QUnit.test('baz', (assert) => { assert.equal(4, 4) })
})
const testNames = []
QUnit.config.modules.forEach((module) => {
testNames.push(...module.tests.map(test => test.name))
})
console.log(testNames)