/
react-webpack-5.test.ts
51 lines (43 loc) · 1.35 KB
/
react-webpack-5.test.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
51
import {
checkFilesExist,
checkFilesDoNotExist,
isNotWindows,
killPorts,
newProject,
readFile,
runCLI,
runCypressTests,
updateFile,
uniq,
} from '@nrwl/e2e/utils';
describe('Webpack 5: React Apps', () => {
it('should successfully build and run E2E tests', async () => {
const appName = uniq('app');
newProject();
runCLI(`generate @nrwl/react:app ${appName} --style css`);
runCLI(`generate @nrwl/web:webpack5`);
// Make the entry file large to make sure it doesn't split
updateFile(
`apps/${appName}/src/styles.css`,
Array.from({ length: 2000 })
.map((_, i) => `.class-${i} { color: red; }`)
.join('\n')
);
runCLI(`build ${appName} --prod --output-hashing none`);
checkFilesExist(
`dist/apps/${appName}/index.html`,
`dist/apps/${appName}/runtime.esm.js`,
`dist/apps/${appName}/main.esm.js`,
`dist/apps/${appName}/styles.css`
);
checkFilesDoNotExist(`dist/apps/${appName}/styles.js`);
expect(readFile(`dist/apps/${appName}/index.html`)).toContain(
`<link rel="stylesheet" href="styles.css">`
);
if (isNotWindows() && runCypressTests()) {
const e2eResults = runCLI(`e2e ${appName}-e2e --headless --no-watch`);
expect(e2eResults).toContain('All specs passed!');
expect(await killPorts()).toBeTruthy();
}
}, 500000);
});