Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 48 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 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 |