-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtest.js
65 lines (62 loc) · 1.6 KB
/
test.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
const path = require('path')
const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const babel = require('rollup-plugin-babel')
const coverage = require('rollup-plugin-coverage')
const alias = require('rollup-plugin-alias')
const TestServer = require('karma').Server
const bundleName = process.env.BUNDLE
const bundlePath = bundleName ? `dist/${bundleName}` : 'src/index.js'
const config = {
frameworks: ['mocha', 'chai', 'source-map-support'],
reporters: ['mocha', 'coverage'],
files: ['tests/**/*.test.js'],
preprocessors: {
'tests/**/*.test.js': ['rollup']
},
rollupPreprocessor: {
plugins: [
alias({
'@nx-js/compiler-util': path.resolve(bundlePath)
}),
babel({
exclude: 'node_modules/**'
}),
resolve(),
commonjs({
namedExports: {
'node_modules/chai/index.js': ['expect']
}
}),
coverage({
include: ['src/**/*.js']
})
],
output: {
format: 'iife',
name: 'compiler',
sourcemap: 'inline'
}
},
coverageReporter: {
dir: 'coverage',
reporters: [{ type: 'lcov', subdir: '.' }, { type: 'text-summary' }]
},
port: 9876,
colors: true,
autoWatch: false,
concurrency: Infinity,
singleRun: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
}
const testServer = new TestServer(config, exitCode => {
console.log(`Karma has exited with ${exitCode}`)
process.exit(exitCode)
})
testServer.start()