/
custom-entry-path.test.js
68 lines (52 loc) · 1.87 KB
/
custom-entry-path.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
66
67
68
/* eslint-disable prettier/prettier */
import karmaChromeLauncher from 'karma-chrome-launcher';
import karmaMocha from 'karma-mocha';
import karmaChai from 'karma-chai';
import Scenario from '../../utils/scenario';
process.env.CHROME_BIN = require('puppeteer').executablePath();
const path = require('path');
const karmaWebpack = require('../../../../lib/index');
// The karma server integration tests take longer than the jest 5 sec default,
// we will give them 30 seconds to complete.
const KARMA_SERVER_TIMEOUT = 30 * 1000;
describe('A basic karma-webpack setup', () => {
let scenario;
const TEST_PATH = path.resolve(__dirname, './index.scenario.js');
const config = {
frameworks: ['mocha', 'chai', 'webpack'],
files: [{ pattern: TEST_PATH }],
preprocessors: { [TEST_PATH]: ['webpack'] },
webpack: {
devtool: false,
entry: './test.js',
},
browsers: ['ChromeHeadless'],
// Explicitly turn off reporters so the simulated test results are not confused with the actual results.
reporters: [],
plugins: [karmaWebpack, karmaChromeLauncher, karmaMocha, karmaChai],
port: 2389,
logLevel: 'ERROR',
singleRun: true
};
beforeAll((done) => {
Scenario.run(config)
.then((res) => {
scenario = res;
})
.catch((err) => console.error('Integration Scenario Failed: ', err))
.finally(() => done());
}, KARMA_SERVER_TIMEOUT);
// karma-webpack should ignore the entry option and throw a warning.
it('should have an exit code of 1 because it contains a failing test', () => {
expect(scenario.exitCode).toBe(1);
})
it('should have three successful test runs', () => {
expect(scenario.success).toBe(3);
});
it('should have one failed test run', () => {
expect(scenario.failed).toBe(1);
});
it('should complete with no errors', () => {
expect(scenario.error).toBe(false);
});
});