feat(testrunner): async suite descriptions (#4721)
This patch teaches TestRunner to support async suite descriptions. This is needed to require tests using ES6 dynamic imports: ```js const t = new TestRunner(); await t.describe('tests', async () => { (await import('./some.spec.js')).addTests(t); (await import('./other.spec.js')).addTests(t); }); ```
This commit is contained in:
parent
835e8849fd
commit
852c46c1e4
@ -327,12 +327,14 @@ class TestRunner extends EventEmitter {
|
|||||||
this._hasFocusedTestsOrSuites = this._hasFocusedTestsOrSuites || mode === TestMode.Focus;
|
this._hasFocusedTestsOrSuites = this._hasFocusedTestsOrSuites || mode === TestMode.Focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
_addSuite(mode, comment, name, callback) {
|
async _addSuite(mode, comment, name, callback) {
|
||||||
const oldSuite = this._currentSuite;
|
const oldSuite = this._currentSuite;
|
||||||
const suite = new Suite(this._currentSuite, name, mode, comment);
|
const suite = new Suite(this._currentSuite, name, mode, comment);
|
||||||
this._currentSuite.children.push(suite);
|
this._currentSuite.children.push(suite);
|
||||||
this._currentSuite = suite;
|
this._currentSuite = suite;
|
||||||
callback();
|
const result = callback();
|
||||||
|
if (result && (typeof result.then === 'function'))
|
||||||
|
await result;
|
||||||
this._currentSuite = oldSuite;
|
this._currentSuite = oldSuite;
|
||||||
this._hasFocusedTestsOrSuites = this._hasFocusedTestsOrSuites || mode === TestMode.Focus;
|
this._hasFocusedTestsOrSuites = this._hasFocusedTestsOrSuites || mode === TestMode.Focus;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user