-
Notifications
You must be signed in to change notification settings - Fork 214
/
webpack.tests.config.js
36 lines (31 loc) · 1.04 KB
/
webpack.tests.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
const webPack = require('./webpack.config')
const fs = require('fs')
const path = require('path')
const readDirRecursiveSync = (folder, filter) => {
const currentPath = fs.readdirSync(folder).map(f => path.join(folder, f))
const files = currentPath.filter(filter)
const directories = currentPath
.filter(f => fs.statSync(f).isDirectory())
.map(f => readDirRecursiveSync(f, filter))
.reduce((cur, next) => [...cur, ...next], [])
return [...files, ...directories]
}
const getEntries = (folder) =>
readDirRecursiveSync(folder, f => f.match(/.*(tests|specs)\.tsx?$/))
.map((file) => {
return {
name: path.basename(file, path.extname(file)),
path: path.resolve(file)
}
})
.reduce((memo, file) => {
memo[file.name] = file.path
return memo
}, {})
module.exports = [
Object.assign({}, webPack[0], {entry: getEntries('./tests/gui/')}),
Object.assign({}, webPack[0], {entry: getEntries('./tests/main/')})
].map(s => {
s.output.path = path.resolve(__dirname, '__tests__')
return s
})