/
source-map-object.test.js
59 lines (48 loc) · 2.06 KB
/
source-map-object.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
'use strict';
const { existsSync } = require('fs');
const { resolve } = require('path');
const { run, readdir } = require('../../../utils/test-utils');
describe('source-map object', () => {
it('should not write a source map for obj config', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.eval.config.js']);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("devtool: 'eval-cheap-module-source-map'");
let files;
try {
files = await readdir(resolve(__dirname, 'dist'));
} catch (error) {
expect(error).toBe(null);
}
expect(files.length).toBeGreaterThanOrEqual(1);
});
it('should write a sourcemap file', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.source.config.js'], false);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("devtool: 'source-map'");
expect(existsSync(resolve(__dirname, 'dist/dist-amd.js.map'))).toBeTruthy();
});
it('should override config with source-map', async () => {
const { exitCode, stderr, stdout } = await run(
__dirname,
['-c', './webpack.eval.config.js', '--devtool', 'source-map', '-o', './binary'],
false,
);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("devtool: 'source-map'");
expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy();
});
it('should override config with devtool false', async () => {
const { exitCode, stderr, stdout } = await run(
__dirname,
['-c', './webpack.eval.config.js', '--no-devtool', '-o', './binary'],
false,
);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain('devtool: false');
expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy();
});
});