-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjest.config.js
86 lines (75 loc) · 2.68 KB
/
jest.config.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import path, { dirname } from 'path';
import { getPluginFolders } from './pluginUnitTests/util.js';
import { fileURLToPath } from 'url';
const pathArg = process.argv.filter((x) => x.startsWith('--path='))[0];
const pluginPath = pathArg ? pathArg.split('=')[1] : null;
const pluginNameArg = process.argv.filter((x) => x.startsWith('--pluginName='))[0];
const pluginName = pluginNameArg ? pluginNameArg.split('=')[1] : null;
const testFileName = pluginName ? pluginName + '.xml' : 'junit-test.xml';
const __dirname = dirname(fileURLToPath(import.meta.url));
const directoryPath = path.join(__dirname, './plugins');
const getPlugins = async (pluginPath) => {
if (pluginPath !== undefined && pluginPath !== null) {
return [{
name: pluginName,
pluginPath: pluginPath
}];
}
else {
return await getPluginFolders(directoryPath);
}
};
export default async () => {
return {
collectCoverageFrom: ['./plugins/**/*.{js,jsx,ts,tsx}'],
coveragePathIgnorePatterns: ['node_modules', '.mock.ts', 'Mocks.ts'],
testMatch: [
'<rootDir>/**/pluginUnitTests/**/*.{spec,test}.{js,jsx,ts,tsx}'
],
globals: {
pluginsToTest: await getPlugins(pluginPath),
pluginDirectoryPath: directoryPath,
baseDirectory: __dirname
},
testPathIgnorePatterns: [],
transform: {
'^.+\\.(t|j)sx?$': [
'@swc-node/jest',
{
jsx: true,
experimentalDecorators: true,
emitDecoratorMetadata: true,
esModuleInterop: true
}
]
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$'],
testEnvironment: 'node',
reporters: [
'default',
[
'jest-html-reporters',
{
publicPath: 'pluginUnitTests/test_output/html',
filename: pluginName + '.html',
expand: true,
pageTitle: pluginName,
inlineSource: true
}
],
[
'jest-junit',
{
outputDirectory: 'pluginUnitTests/test_output',
outputName: testFileName,
suiteName: 'Plugin Unit Test',
noStackTrace: true,
ancestorSeparator: ' › ',
titleTemplate: '{classname} : {title}',
classNameTemplate: '{classname} : {title}'
}
]
],
setupFiles: []
};
};