forked from ing-bank/lion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallaby.js
46 lines (41 loc) · 1.48 KB
/
wallaby.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
const wallabyWebpack = require('wallaby-webpack'); // eslint-disable-line import/no-extraneous-dependencies
// filter packages, e.g. 'core' / '{radio,radio-button}' / '{form,input*}'
const packagePattern = '*';
const replaceAll = (str, oldValue, newValue) => {
return str.split(oldValue).join(newValue);
};
const countOccurences = (str, subbstr) => {
return str.split(subbstr).length - 1;
};
const makeLionImportsRelative = file => {
// example:
// file.path: 'packages/package-name/src/my-element.js'
// old imports: '@lion/package-name'
// new imports: '../../package-name'
const nestLevel = countOccurences(file.path, '/') - 1; // 3 - 1 = 2
return replaceAll(file.content, '@lion/', '../'.repeat(nestLevel)); // '@lion/' => '../../'
};
module.exports = () => ({
files: [
{ pattern: `packages/${packagePattern}/*.js`, load: false },
{ pattern: `packages/${packagePattern}/{src,translations,test}/**/*.js`, load: false },
{ pattern: `packages/${packagePattern}/test/**/*.test.js`, ignore: true },
],
filesWithNoCoverageCalculated: [
`packages/${packagePattern}/*.js`,
`packages/${packagePattern}/test/**/*.js`,
],
tests: [{ pattern: `packages/${packagePattern}/test/**/*.test.js`, load: false }],
testFramework: 'mocha',
env: {
kind: 'chrome',
},
preprocessors: {
'**/*.js': makeLionImportsRelative,
},
postprocessor: wallabyWebpack(),
setup: () => {
// required to trigger test loading
window.__moduleBundler.loadTests();
},
});