Passed
Push — master ( 9423ce...f03429 )
by Dmytro
01:57
created

tests/Benchmark/reports.test.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 48
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 30
mnd 0
bc 0
fnc 2
dl 0
loc 48
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import { pause } from 'myrmidon';
2
import { assert } from 'chai';
3
import { BenchMark, JSONReporter } from '../entry';
4
import { checkReportItem, getReportItem } from '../utils';
5
6
suite('Benchmark reports');
7
8
test('Positive: pretty json', async function () {
9
    const bench = new BenchMark({});
10
11
    bench.sequence('before');
12
    await pause(2010);
13
    bench.sequence('after');
14
15
    const report = JSON.parse(
16
        bench.report(new JSONReporter(), { pretty: true })
17
    );
18
19
    checkReportItem(report, 'before', 'benchmark', 0);
20
    assert.match(
21
        getReportItem(report, 'after').benchmark,
22
        /2s \d+ms/
23
    );
24
});
25
26
27
test('Positive: pretty config', async function () {
28
    const bench = new BenchMark({});
29
30
    bench.sequence('before');
31
    await pause(120);
32
    bench.sequence('after');
33
34
    const report = JSON.parse(
35
        bench.report(new JSONReporter(), {
36
            pretty : {
37
                exclude : [ 'total' ],
38
                include : [ 'mean', 'benchmark' ]
39
            }
40
        })
41
    );
42
43
    checkReportItem(report, 'before', 'benchmark', 0);
44
    assert.match(
45
        getReportItem(report, 'after').benchmark,
46
        /1\d+ms/
47
    );
48
});
49
50