forked from bluebeel/now-builders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
40 lines (32 loc) · 939 Bytes
/
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
const childProcess = require('child_process');
const path = require('path');
const command = 'git diff HEAD~1 --name-only';
const diff = childProcess.execSync(command).toString();
const changed = diff
.split('\n')
.filter(item => Boolean(item) && item.includes('packages/'))
.map(item => path.relative('packages', item).split('/')[0]);
const matches = [];
if (changed.length > 0) {
console.log('The following packages have changed:');
changed.map((item) => {
matches.push(item);
console.log(item);
return null;
});
} else {
matches.push('now-node');
console.log(`No packages changed, defaulting to ${matches[0]}`);
}
const testMatch = Array.from(new Set(matches)).map(
item => `**/${item}/**/?(*.)+(spec|test).[jt]s?(x)`,
);
module.exports = {
testEnvironment: 'node',
testMatch,
collectCoverageFrom: [
'packages/(!test)/**/*.{js,jsx}',
'!**/node_modules/**',
'!**/test/**',
],
};