-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
web-vite.test.ts
92 lines (75 loc) · 2.84 KB
/
web-vite.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {
checkFilesDoNotExist,
checkFilesExist,
cleanupProject,
createFile,
isNotWindows,
killPorts,
newProject,
removeFile,
runCLI,
runCLIAsync,
runCypressTests,
uniq,
} from '@nrwl/e2e/utils';
describe('Web Components Applications with bundler set as vite', () => {
beforeEach(() => newProject());
afterEach(() => cleanupProject());
it('should be able to generate a web app', async () => {
const appName = uniq('app');
runCLI(`generate @nrwl/web:app ${appName} --bundler=vite --no-interactive`);
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('All files pass linting.');
runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/index.html`);
const testResults = await runCLIAsync(`test ${appName}`);
expect(testResults.combinedOutput).toContain('Tests 2 passed (2)');
const lintE2eResults = runCLI(`lint ${appName}-e2e`);
expect(lintE2eResults).toContain('All files pass linting.');
if (isNotWindows() && runCypressTests()) {
const e2eResults = runCLI(`e2e ${appName}-e2e --no-watch`);
expect(e2eResults).toContain('All specs passed!');
expect(await killPorts()).toBeTruthy();
}
}, 500000);
it('should be able to generate a web app with standaloneConfig', async () => {
const appName = uniq('app');
runCLI(
`generate @nrwl/web:app ${appName} --bundler=vite --no-interactive --standalone-config`
);
checkFilesExist(`apps/${appName}/project.json`);
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('All files pass linting.');
}, 120000);
it('should remove previous output before building', async () => {
const appName = uniq('app');
const libName = uniq('lib');
runCLI(`generate @nrwl/web:app ${appName} --bundler=vite --no-interactive`);
runCLI(
`generate @nrwl/react:lib ${libName} --buildable --no-interactive --compiler swc`
);
createFile(`dist/apps/${appName}/_should_remove.txt`);
createFile(`dist/libs/${libName}/_should_remove.txt`);
createFile(`dist/apps/_should_not_remove.txt`);
checkFilesExist(
`dist/apps/${appName}/_should_remove.txt`,
`dist/apps/_should_not_remove.txt`
);
runCLI(`build ${appName}`);
runCLI(`build ${libName}`);
checkFilesDoNotExist(
`dist/apps/${appName}/_should_remove.txt`,
`dist/libs/${libName}/_should_remove.txt`
);
checkFilesExist(`dist/apps/_should_not_remove.txt`);
}, 120000);
it('should support workspaces w/o workspace config file', async () => {
removeFile('workspace.json');
const myapp = uniq('myapp');
runCLI(`generate @nrwl/web:app ${myapp} --bundler=vite --directory=myDir`);
runCLI(`build my-dir-${myapp}`);
expect(() =>
checkFilesDoNotExist('workspace.json', 'angular.json')
).not.toThrow();
}, 1000000);
});