-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
36 lines (34 loc) · 1.74 KB
/
main.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
import Retry from './src/retry.js'
export default function setup (testFn, { maxRuns: defaultMaxRuns = 2, beforeRetry } = {}) {
const retry = function (name, callback, maxRuns = defaultMaxRuns) {
return new Retry([name], callback, maxRuns, testFn, beforeRetry)
}
retry.todo = function (name, callback, maxRuns = defaultMaxRuns) {
return new Retry([name], callback, maxRuns, testFn.todo, beforeRetry)
}
retry.skip = function (name, callback, maxRuns = defaultMaxRuns) {
return new Retry([name], callback, maxRuns, testFn.skip, beforeRetry)
}
retry.if = function (name, condition, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, condition], callback, maxRuns, testFn.if, beforeRetry)
}
retry.only = function (name, callback, maxRuns = defaultMaxRuns) {
return new Retry([name], callback, maxRuns, testFn.only, beforeRetry)
}
retry.each = function (name, dataset, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, dataset], callback, maxRuns, testFn.each, beforeRetry)
}
retry.todo.each = function (name, dataset, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, dataset], callback, maxRuns, testFn.todo.each, beforeRetry)
}
retry.skip.each = function (name, dataset, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, dataset], callback, maxRuns, testFn.skip.each, beforeRetry)
}
retry.if.each = function (name, condition, dataset, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, condition, dataset], callback, maxRuns, testFn.if.each, beforeRetry)
}
retry.only.each = function (name, dataset, callback, maxRuns = defaultMaxRuns) {
return new Retry([name, dataset], callback, maxRuns, testFn.only.each, beforeRetry)
}
return retry
}