-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
31 lines (27 loc) · 853 Bytes
/
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
/**
*
* @param {string} name - Test name
* @param {Object} options
* @param {boolean} options.merge - If true, merge entries instead of replacing them in final output.
* @param {number} options.runCount - Number of times to run the test.options
* @param {string} options.outPath - Path to output file
* @param {function} _test - Test body to pass into `it`
*/
function benchmark(name, { merge = true, runCount = 1, outPath = 'benchmark.json' } = {}, _test) {
let test;
if (arguments.length < 3) {
// assume that second param is test
test = arguments[1];
} else {
test = _test;
}
describe(name, () => {
after(() => {
cy.task('writeBenchmarkFile', { path: outPath, content: Cypress.measures, merge });
});
Cypress._.times(runCount, i => {
it(`Run ${i + 1}`, { retries: 0 }, test);
});
});
}
export default benchmark;