-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
web.test.ts
69 lines (64 loc) · 2.36 KB
/
web.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
import {
checkFilesExist,
ensureProject,
readFile,
runCLI,
runCLIAsync,
uniq,
forEachCli,
supportUi
} from './utils';
forEachCli(currentCLIName => {
describe('Web Components Applications', () => {
it('should be able to generate a web app', async () => {
ensureProject();
const appName = uniq('app');
const linter = currentCLIName === 'angular' ? 'tslint' : 'eslint';
runCLI(
`generate @nrwl/web:app ${appName} --no-interactive --linter=${linter}`
);
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('All files pass linting.');
runCLI(`build ${appName}`);
checkFilesExist(
`dist/apps/${appName}/index.html`,
`dist/apps/${appName}/polyfills-es2015.js`,
`dist/apps/${appName}/runtime-es2015.js`,
`dist/apps/${appName}/main-es2015.js`,
`dist/apps/${appName}/styles-es2015.js`,
`dist/apps/${appName}/polyfills-es5.js`,
`dist/apps/${appName}/runtime-es5.js`,
`dist/apps/${appName}/main-es5.js`,
`dist/apps/${appName}/styles-es5.js`
);
expect(readFile(`dist/apps/${appName}/main-es5.js`)).toContain(
'var AppElement = /** @class */ (function (_super) {'
);
expect(readFile(`dist/apps/${appName}/main-es2015.js`)).toContain(
'class AppElement'
);
runCLI(`build ${appName} --prod --output-hashing none`);
checkFilesExist(
`dist/apps/${appName}/index.html`,
`dist/apps/${appName}/polyfills-es2015.js`,
`dist/apps/${appName}/runtime-es2015.js`,
`dist/apps/${appName}/main-es2015.js`,
`dist/apps/${appName}/polyfills-es5.js`,
`dist/apps/${appName}/runtime-es5.js`,
`dist/apps/${appName}/main-es5.js`,
`dist/apps/${appName}/styles.css`
);
expect(readFile(`dist/apps/${appName}/index.html`)).toContain(
`<link rel="stylesheet" href="styles.css">`
);
const testResults = await runCLIAsync(`test ${appName}`);
expect(testResults.stderr).toContain('Test Suites: 1 passed, 1 total');
const lintE2eResults = runCLI(`lint ${appName}-e2e`);
expect(lintE2eResults).toContain('All files pass linting.');
if (supportUi()) {
const e2eResults = runCLI(`e2e ${appName}-e2e`);
expect(e2eResults).toContain('All specs passed!');
}
}, 120000);
});
});