UNPKG

create-lite-jest-runner

Version:
30 lines 988 B
import pLimit from "p-limit"; export default (run) => class LiteTestRunner { _globalConfig; _context; constructor(_globalConfig, _context = {}) { this._globalConfig = _globalConfig; this._context = _context; this._globalConfig = _globalConfig; this._context = _context; } async runTests(tests, _, onStart, onResult, onFailure) { const limit = pLimit(this._globalConfig.maxWorkers); const promises = tests.map((test) => limit(async () => { await onStart(test); try { const result = await run({ testPath: test.path, context: test.context, }); await onResult(test, result); } catch (error) { await onFailure(test, error); } })); await Promise.all(promises); } }; export { pass, fail } from "./results.js"; //# sourceMappingURL=index.js.map