-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallaby.config.js
78 lines (70 loc) · 1.87 KB
/
wallaby.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
const fs = require('fs');
const path = require('path');
/**
* Returns array of all folders that contain Azure Functions.
*
* @return {Array<string>}
*/
const azFunctionFolders = function () {
return fs.readdirSync(__dirname)
.filter(folder => fs.existsSync(path.resolve(__dirname, folder, 'function.json')));
};
/**
* Returns array of all files to include when copying to the Wallaby.js work folder.
*
* @return {Array<string>}
*/
const getFilesToInclude = function () {
let files = [];
// add supporting files
files.push(
'config/jest.config.js',
'*.d.ts',
'package.json',
'**/__mocks__/**/*.*',
'**/function.json'
);
// include all code files in subfolders
Array.prototype.push.apply(
files,
azFunctionFolders().map(functionFolder => `${functionFolder}/**/*.ts`)
);
// exclude the test files
files.push(
'!**/*.spec.ts'
);
return files;
}
/**
* Returns array of all spec files to include executing the test runner.
*
* @return {Array<string>}
*/
const getTestFilesToInclude = function () {
return azFunctionFolders().map(functionFolder => `${functionFolder}/**/*.spec.ts`);
}
module.exports = function (wallaby) {
return {
debug: true,
files: getFilesToInclude(),
tests: getTestFilesToInclude(),
filesWithNoCoverageCalculated: [
'**/__mocks__/**/*.ts'
],
compilers: {
'**/*.ts': wallaby.compilers.typeScript({ module: 'commonjs' })
},
env: { type: 'node' },
testFramework: 'jest',
setup: function (wallaby) {
const jestConfig = require('./config/jest.config.js');
wallaby.testFramework.configure(jestConfig);
},
preprocessors: {
// required for mocks to work
'**/*.js?(x)': file => require('@babel/core').transform(
file.content,
{ sourceMap: true, filename: file.path, presets: [require('babel-preset-jest')] })
}
};
};