Issues (6)

tests/utils.js (1 issue)

1
import path from 'path';
2
import { assert } from 'chai';
3
import { entry } from './constants';
4
5
export function load(relPath, clearCache) {
6
    const absPath = path.resolve(entry, relPath);
7
8
    if (clearCache) delete require.cache[require.resolve(absPath)];
9
    // eslint-disable-next-line security/detect-non-literal-require
10
    const result =  require(absPath);
11
12
    if (clearCache) delete require.cache[require.resolve(absPath)];
13
14
    return result;
15
}
16
17
export function resolve(relPath) {
18
    return require.resolve(path.join(entry, relPath));
19
}
20
21
export async function ensureError(handler) {
22
    try {
23
        await handler();
24
        assert.fail('Expected to throw an error');
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
25
    } catch (error)  {
26
        if (error.name === 'AssertionError') throw error;
27
28
        return error;
29
    }
30
}
31