forked from tagspaces/tagspaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.unit.js
69 lines (67 loc) · 1.97 KB
/
jest.config.unit.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// const sh = require('shelljs');
const branchName = require('current-git-branch');
const isWin = /^win/.test(process.platform);
const isMac = /^darwin/.test(process.platform);
const isLinux = /^linux/.test(process.platform);
let os = '';
if (isWin) {
os = '_win';
} else if (isMac) {
os = '_macos';
} else if (isLinux) {
os = '_linux';
}
const web = process.env.NODE_JEST === 'test_web' ? '_web' : '';
const minio = process.env.NODE_JEST === 'test_minio' ? '_minio' : '';
module.exports = async () => {
/* const BRANCH_NAME = await new Promise((resolve, reject) => {
sh.exec(
'git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3',
(code, stdout, stderr) => {
if (code !== 0) {
const e = new Error();
e.message = stderr;
e.name = String(code);
reject(e);
} else {
resolve(stdout);
}
}
);
}); */
const BRANCH_NAME = branchName();
return {
rootDir: './tests',
verbose: true,
/**
* setupFiles: ran once per test file before all tests
* https://jestjs.io/docs/en/configuration#setupfiles-array
*/
setupFiles: ['../scripts/test-config-unit.js'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/internals/mocks/fileMock.js',
'\\.(css|less|sass|scss)$': 'identity-obj-proxy'
},
moduleFileExtensions: ['js', 'ts', 'tsx'],
moduleDirectories: ['node_modules', 'app/node_modules'],
testMatch: [
'**/{unit,e2e,app,test,integration}/**/*.{test,e2e}.{js,tsx,ts,tsx}'
],
testPathIgnorePatterns: ['<rootDir>/extensions'],
reporters: [
'default',
[
'../node_modules/jest-html-reporter',
{
pageTitle: BRANCH_NAME + ' Test Report',
outputPath:
'./test-reports/' + BRANCH_NAME + os + web + minio + '.html'
}
],
'jest-junit'
],
collectCoverage: true,
maxWorkers: 1
};
};