-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
migrate-to-webpack-5.spec.ts
50 lines (41 loc) · 1.39 KB
/
migrate-to-webpack-5.spec.ts
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
import { readJson, Tree, updateJson } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import { nodeMigrateToWebpack5Generator } from './migrate-to-webpack-5';
describe('nodeMigrateToWebpack5Generator', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
updateJson(tree, 'package.json', (json) => {
json.devDependencies = {
'@nrwl/cli': '100.0.0',
'@nrwl/jest': '100.0.0',
'@nrwl/node': '100.0.0',
'@nrwl/workspace': '100.0.0',
};
return json;
});
});
it('should add packages needed by Node', async () => {
await nodeMigrateToWebpack5Generator(tree, {});
const json = readJson(tree, '/package.json');
expect(json.devDependencies['webpack']).toMatch(/\^5/);
});
it('should add packages needed by Web if used', async () => {
updateJson(tree, 'package.json', (json) => {
json.devDependencies = {
'@nrwl/cli': '100.0.0',
'@nrwl/jest': '100.0.0',
'@nrwl/node': '100.0.0',
'@nrwl/react': '100.0.0',
'@nrwl/web': '100.0.0',
'@nrwl/workspace': '100.0.0',
};
return json;
});
await nodeMigrateToWebpack5Generator(tree, {});
const json = readJson(tree, '/package.json');
expect(
json.devDependencies['@pmmmwh/react-refresh-webpack-plugin']
).toMatch(/^0\.5/);
});
});