Skip to content

Commit 99fa7bd

Browse files
clydinvikerman
authored andcommitted
test: add initial ivy large test support
1 parent 9b2a38c commit 99fa7bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1372
-327
lines changed

.circleci/config.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ jobs:
123123
steps:
124124
- attach_workspace: *attach_options
125125
- run: yarn webdriver-update
126-
- run: yarn test-large -- --full --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
126+
- run: yarn test-large --full --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
127+
128+
test-large-ivy:
129+
<<: *defaults
130+
docker:
131+
- image: *browsers_docker_image
132+
resource_class: large
133+
parallelism: 4
134+
steps:
135+
- attach_workspace: *attach_options
136+
- run: yarn webdriver-update
137+
- run: yarn test-large --ivy --full --glob="packages/angular_devkit/build_angular/test/browser/*_spec_large.ts" --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
127138

128139
e2e-cli:
129140
<<: *defaults
@@ -292,6 +303,9 @@ workflows:
292303
- test-large:
293304
requires:
294305
- build
306+
- test-large-ivy:
307+
requires:
308+
- build
295309
- e2e-cli:
296310
requires:
297311
- build

packages/angular_devkit/build_angular/test/browser/aot_spec_large.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import { Architect } from '@angular-devkit/architect';
1010
import { join, normalize, virtualFs } from '@angular-devkit/core';
1111
import { BrowserBuilderOutput } from '../../src/browser';
12-
import { createArchitect, host } from '../utils';
13-
12+
import { createArchitect, host, ivyEnabled } from '../utils';
1413

1514
describe('Browser Builder AOT', () => {
1615
const targetSpec = { project: 'app', target: 'build' };
@@ -26,13 +25,17 @@ describe('Browser Builder AOT', () => {
2625
const overrides = { aot: true };
2726

2827
const run = await architect.scheduleTarget(targetSpec, overrides);
29-
const output = await run.result as BrowserBuilderOutput;
28+
const output = (await run.result) as BrowserBuilderOutput;
3029

3130
expect(output.success).toBe(true);
3231

3332
const fileName = join(normalize(output.outputPath), 'main.js');
3433
const content = virtualFs.fileBufferToString(await host.read(normalize(fileName)).toPromise());
35-
expect(content).toMatch(/platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/);
34+
if (ivyEnabled) {
35+
expect(content).toContain('AppComponent.ngComponentDef');
36+
} else {
37+
expect(content).toMatch(/platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/);
38+
}
3639

3740
await run.stop();
3841
});

packages/angular_devkit/build_angular/test/browser/errors_spec_large.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import { Architect } from '@angular-devkit/architect';
1010
import { logging } from '@angular-devkit/core';
11-
import { createArchitect, host } from '../utils';
12-
11+
import { createArchitect, host, ivyEnabled } from '../utils';
1312

1413
describe('Browser Builder errors', () => {
1514
const targetSpec = { project: 'app', target: 'build' };
@@ -22,10 +21,14 @@ describe('Browser Builder errors', () => {
2221
afterEach(async () => host.restore().toPromise());
2322

2423
it('shows error when files are not part of the compilation', async () => {
25-
host.replaceInFile('src/tsconfig.app.json', '"compilerOptions": {', `
24+
host.replaceInFile(
25+
'src/tsconfig.app.json',
26+
'"compilerOptions": {',
27+
`
2628
"files": ["main.ts"],
2729
"compilerOptions": {
28-
`);
30+
`,
31+
);
2932
const logger = new logging.Logger('');
3033
const logs: string[] = [];
3134
logger.subscribe(e => logs.push(e.message));
@@ -59,7 +62,11 @@ describe('Browser Builder errors', () => {
5962
const run = await architect.scheduleTarget(targetSpec, { aot: true }, { logger });
6063
const output = await run.result;
6164
expect(output.success).toBe(false);
62-
expect(logs.join()).toContain('Function expressions are not supported in');
65+
if (ivyEnabled) {
66+
expect(logs.join()).toContain('selector must be a string');
67+
} else {
68+
expect(logs.join()).toContain('Function expressions are not supported in');
69+
}
6370
await run.stop();
6471
});
6572

packages/angular_devkit/build_angular/test/browser/i18n_spec_large.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import { Architect } from '@angular-devkit/architect';
99
import { join, normalize, virtualFs } from '@angular-devkit/core';
1010
import { BrowserBuilderOutput } from '../../src/browser';
11-
import { createArchitect, host } from '../utils';
11+
import { createArchitect, host, ivyEnabled } from '../utils';
1212

13-
14-
describe('Browser Builder i18n', () => {
13+
// DISABLED_FOR_IVY - These should pass but are currently not supported
14+
(ivyEnabled ? xdescribe : describe)('Browser Builder i18n', () => {
1515
const emptyTranslationFile = `
1616
<?xml version="1.0" encoding="UTF-8" ?>
1717
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
@@ -48,8 +48,10 @@ describe('Browser Builder i18n', () => {
4848
`,
4949
});
5050

51-
host.appendToFile('src/app/app.component.html',
52-
'<h1 i18n="An introduction header for this sample">Hello i18n!</h1>');
51+
host.appendToFile(
52+
'src/app/app.component.html',
53+
'<h1 i18n="An introduction header for this sample">Hello i18n!</h1>',
54+
);
5355

5456
const overrides = {
5557
aot: true,
@@ -59,7 +61,7 @@ describe('Browser Builder i18n', () => {
5961
};
6062

6163
const run = await architect.scheduleTarget(targetSpec, overrides);
62-
const output = await run.result as BrowserBuilderOutput;
64+
const output = (await run.result) as BrowserBuilderOutput;
6365
expect(output.success).toBe(true);
6466
const outputPath = output.outputPath;
6567
const fileName = join(normalize(outputPath), 'main.js');
@@ -82,7 +84,7 @@ describe('Browser Builder i18n', () => {
8284
host.appendToFile('src/app/app.component.html', '<p i18n>Other content</p>');
8385

8486
const run = await architect.scheduleTarget(targetSpec, overrides);
85-
const output = await run.result as BrowserBuilderOutput;
87+
const output = (await run.result) as BrowserBuilderOutput;
8688
expect(output.success).toBe(true);
8789
const outputPath = output.outputPath;
8890
const fileName = join(normalize(outputPath), 'main.js');
@@ -105,7 +107,7 @@ describe('Browser Builder i18n', () => {
105107
host.appendToFile('src/app/app.component.html', '<p i18n>Other content</p>');
106108

107109
const run = await architect.scheduleTarget(targetSpec, overrides);
108-
const output = await run.result as BrowserBuilderOutput;
110+
const output = (await run.result) as BrowserBuilderOutput;
109111
expect(output.success).toBe(false);
110112

111113
await run.stop();
@@ -115,7 +117,7 @@ describe('Browser Builder i18n', () => {
115117
const overrides = { aot: true, i18nLocale: 'fr_FR' };
116118

117119
const run = await architect.scheduleTarget(targetSpec, overrides);
118-
const output = await run.result as BrowserBuilderOutput;
120+
const output = (await run.result) as BrowserBuilderOutput;
119121
expect(output.success).toBe(true);
120122
const outputPath = output.outputPath;
121123
const fileName = join(normalize(outputPath), 'main.js');

packages/angular_devkit/build_angular/test/browser/lazy-module_spec_large.ts

+61-31
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ import { Architect } from '@angular-devkit/architect';
1010
import { TestLogger } from '@angular-devkit/architect/testing';
1111
import { take, tap, timeout } from 'rxjs/operators';
1212
import {
13-
browserBuild, createArchitect, host, lazyModuleFiles,
14-
lazyModuleFnImport, lazyModuleStringImport,
13+
browserBuild,
14+
createArchitect,
15+
host,
16+
ivyEnabled,
17+
lazyModuleFiles,
18+
lazyModuleFnImport,
19+
lazyModuleStringImport,
1520
} from '../utils';
1621

1722
// tslint:disable-next-line:no-big-function
@@ -25,10 +30,11 @@ describe('Browser Builder lazy modules', () => {
2530
});
2631
afterEach(async () => host.restore().toPromise());
2732

28-
for (const [name, imports] of Object.entries({
29-
'string': lazyModuleStringImport,
30-
'function': lazyModuleFnImport,
31-
})) {
33+
const cases: [string, Record<string, string>][] = [
34+
['string', lazyModuleStringImport],
35+
['function', lazyModuleFnImport],
36+
];
37+
for (const [name, imports] of cases) {
3238
describe(`Load children ${name} syntax`, () => {
3339
it('supports lazy bundle for lazy routes with JIT', async () => {
3440
host.writeMultipleFiles(lazyModuleFiles);
@@ -39,34 +45,46 @@ describe('Browser Builder lazy modules', () => {
3945
});
4046

4147
it('should show error when lazy route is invalid on watch mode AOT', async () => {
48+
if (ivyEnabled && name === 'string') {
49+
pending('Does not apply to Ivy.');
50+
51+
return;
52+
}
53+
54+
// DISABLED_FOR_IVY - These should pass but are currently not supported
55+
if (ivyEnabled) {
56+
pending('Broken in Ivy');
57+
58+
return;
59+
}
60+
4261
host.writeMultipleFiles(lazyModuleFiles);
4362
host.writeMultipleFiles(imports);
44-
host.replaceInFile(
45-
'src/app/app.module.ts',
46-
'lazy.module',
47-
'invalid.module',
48-
);
63+
host.replaceInFile('src/app/app.module.ts', 'lazy.module', 'invalid.module');
4964

5065
const logger = new TestLogger('rebuild-lazy-errors');
5166
const overrides = { watch: true, aot: true };
5267
const run = await architect.scheduleTarget(target, overrides, { logger });
53-
await run.output.pipe(
54-
timeout(15000),
55-
tap((buildEvent) => expect(buildEvent.success).toBe(false)),
56-
tap(() => {
57-
// Webpack error when using loadchildren string syntax.
58-
const hasMissingModuleError = logger.includes('Could not resolve module')
59-
// TS type error when using import().
60-
|| logger.includes('Cannot find module')
61-
// Webpack error when using import() on a rebuild.
62-
// There is no TS error because the type checker is forked on rebuilds.
63-
|| logger.includes('Module not found');
64-
expect(hasMissingModuleError).toBe(true, 'Should show missing module error');
65-
logger.clear();
66-
host.appendToFile('src/main.ts', ' ');
67-
}),
68-
take(2),
69-
).toPromise();
68+
await run.output
69+
.pipe(
70+
timeout(15000),
71+
tap(buildEvent => expect(buildEvent.success).toBe(false)),
72+
tap(() => {
73+
// Webpack error when using loadchildren string syntax.
74+
const hasMissingModuleError =
75+
logger.includes('Could not resolve module') ||
76+
// TS type error when using import().
77+
logger.includes('Cannot find module') ||
78+
// Webpack error when using import() on a rebuild.
79+
// There is no TS error because the type checker is forked on rebuilds.
80+
logger.includes('Module not found');
81+
expect(hasMissingModuleError).toBe(true, 'Should show missing module error');
82+
logger.clear();
83+
host.appendToFile('src/main.ts', ' ');
84+
}),
85+
take(2),
86+
)
87+
.toPromise();
7088
await run.stop();
7189
});
7290

@@ -75,7 +93,13 @@ describe('Browser Builder lazy modules', () => {
7593
host.writeMultipleFiles(imports);
7694

7795
const { files } = await browserBuild(architect, host, target, { aot: true });
78-
expect(files['lazy-lazy-module-ngfactory.js']).not.toBeUndefined();
96+
if (ivyEnabled) {
97+
const data = await files['lazy-lazy-module.js'];
98+
expect(data).not.toBeUndefined('Lazy module output bundle does not exist');
99+
expect(data).toContain('LazyModule.ngModuleDef');
100+
} else {
101+
expect(files['lazy-lazy-module-ngfactory.js']).not.toBeUndefined();
102+
}
79103
});
80104
});
81105
}
@@ -206,8 +230,14 @@ describe('Browser Builder lazy modules', () => {
206230
const { files } = await browserBuild(architect, host, target, {
207231
lazyModules: ['src/app/lazy/lazy.module'],
208232
aot: true,
209-
optimization: true,
210233
});
211-
expect(files['src-app-lazy-lazy-module-ngfactory.js']).not.toBeUndefined();
234+
235+
if (ivyEnabled) {
236+
const data = await files['src-app-lazy-lazy-module.js'];
237+
expect(data).not.toBeUndefined('Lazy module output bundle does not exist');
238+
expect(data).toContain('LazyModule.ngModuleDef');
239+
} else {
240+
expect(files['src-app-lazy-lazy-module-ngfactory.js']).not.toBeUndefined();
241+
}
212242
});
213243
});

packages/angular_devkit/build_angular/test/browser/no-entry-module_spec_large.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import { Architect } from '@angular-devkit/architect';
1010
import { TestLogger } from '@angular-devkit/architect/testing';
11-
import { browserBuild, createArchitect, host } from '../utils';
12-
11+
import { browserBuild, createArchitect, host, ivyEnabled } from '../utils';
1312

1413
describe('Browser Builder no entry module', () => {
1514
const target = { project: 'app', target: 'build' };
@@ -30,6 +29,12 @@ describe('Browser Builder no entry module', () => {
3029
});
3130

3231
it('reports warning when no bootstrap code', async () => {
32+
if (ivyEnabled) {
33+
pending('Does not apply to Ivy.');
34+
35+
return;
36+
}
37+
3338
host.replaceInFile('src/main.ts', /./g, '');
3439
host.appendToFile('src/main.ts', `import './app/app.module';`);
3540

0 commit comments

Comments
 (0)