tests/Test.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 26
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 16
mnd 0
bc 0
fnc 4
dl 0
loc 26
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

3 Functions

Rating   Name   Duplication   Size   Complexity  
A Test.setTmpFolder 0 4 1
A Test.getTraces 0 5 2
A Test.cleanTmpFolder 0 3 1
1
import fse from 'fs-extra';
2
import { getNamespace } from 'cls-hooked';
3
import { tmpFolder } from './constants';
4
import { traces } from './mock';
5
import './init-hooks';
6
7
8
export * from './utils';
9
export * from './constants';
10
11
export default class Test {
12
    async setTmpFolder() {
13
        await this.cleanTmpFolder();
14
        await fse.ensureDir(tmpFolder);
15
    }
16
17
    async cleanTmpFolder() {
18
        await fse.remove(tmpFolder);
19
    }
20
21
    getTraces() {
22
        const traceID = getNamespace('__TEST__').get('current').id;
23
24
        return traces.filter(t => t.type === 'requestSent' && t.traceId === traceID);
25
    }
26
}
27