-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (33 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
const _ = require('lodash');
const parseConfig = require('./lib/parse-config');
const RetryManager = require('./lib/retry-manager');
module.exports = (testplane, opts) => {
if (testplane.isWorker()) {
return;
}
const config = parseConfig(opts);
if (!config.enabled) {
return;
}
const retryManager = new RetryManager(config);
testplane.on(testplane.events.RUNNER_START, () => {
retryManager.clear();
});
testplane.config.getBrowserIds().forEach((browserId) => {
const browserConfig = testplane.config.forBrowser(browserId);
const oldShouldRetry = browserConfig.shouldRetry;
browserConfig.shouldRetry = (options) => {
if (typeof oldShouldRetry === 'function') {
if (oldShouldRetry(options)) {
return true;
}
}
const {ctx, retriesLeft} = options;
const testId = `${ctx.fullTitle()} (${browserId})`;
const errorMessage = _.get(ctx, 'err.message', '');
const extraRetry = retryManager.updateExtraRetry(testId, errorMessage);
return retriesLeft + extraRetry > 0;
};
});
};