Skip to content

Commit 3d6f4ae

Browse files
committed
test: fix large tests for webpack VFS support
1 parent 801da7e commit 3d6f4ae

29 files changed

+170
-177
lines changed

packages/angular_devkit/build_webpack/src/angular-cli-files/models/webpack-configs/typescript.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { WebpackConfigOptions } from '../build-options';
1414
const SilentError = require('silent-error');
1515

1616

17-
const g: any = global;
18-
const webpackLoader: string = g['angularCliIsLocal']
19-
? g.angularCliPackages['@ngtools/webpack'].main
17+
const g: any = typeof global !== 'undefined' ? global : {};
18+
const webpackLoader: string = g['_DevKitIsLocal']
19+
? require('lib/packages').packages['@ngtool/webpack'].main
2020
: '@ngtools/webpack';
2121

2222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Browser Builder', () => {
2424
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
2525
tap(() => {
2626
const fileName = join(outputPath, 'main.js');
27-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
27+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
2828
expect(content).toMatch(/platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/);
2929
}),
3030
).subscribe(undefined, done.fail, done);

packages/angular_devkit/build_webpack/test/browser/assets_spec_large.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ describe('Browser Builder assets', () => {
4242
tap(() => {
4343
// Assets we expect should be there.
4444
Object.keys(matches).forEach(fileName => {
45-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
45+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
4646
expect(content).toMatch(matches[fileName]);
4747
});
4848
// .gitkeep should not be there.
49-
expect(host.asSync().exists(normalize('./dist/folder/.gitkeep'))).toBe(false);
49+
expect(host.scopedSync().exists(normalize('./dist/folder/.gitkeep'))).toBe(false);
5050
}),
5151
).subscribe(undefined, done.fail, done);
5252
}, 30000);

packages/angular_devkit/build_webpack/test/browser/base-href_spec_large.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Browser Builder base href', () => {
2929
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
3030
tap(() => {
3131
const fileName = join(outputPath, 'index.html');
32-
const content = virtualFs.fileBufferToString(host.asSync().read(fileName));
32+
const content = virtualFs.fileBufferToString(host.scopedSync().read(fileName));
3333
expect(content).toMatch(/<base href="\/myUrl">/);
3434
}),
3535
).subscribe(undefined, done.fail, done);

packages/angular_devkit/build_webpack/test/browser/build-optimizer_spec_large.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Browser Builder build optimizer', () => {
2323
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
2424
tap(() => {
2525
const fileName = join(outputPath, 'main.js');
26-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
26+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
2727
expect(content).not.toMatch(/\.decorators =/);
2828
}),
2929
).subscribe(undefined, done.fail, done);

packages/angular_devkit/build_webpack/test/browser/custom-lazy-modules_spec_large.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// concatMap(() => architect.run(architect.getTarget({ overrides }))),
5252
// tap((buildEvent) => expect(buildEvent.success).toBe(true)),
5353
// tap(() =>
54-
// expect(host.asSync().exists(join(outputPath, 'lazy.module.js'))).toBe(true)),
54+
// expect(host.scopedSync().exists(join(outputPath, 'lazy.module.js'))).toBe(true)),
5555
// ).subscribe(undefined, done.fail, done);
5656
// }, 30000);
5757
// });

packages/angular_devkit/build_webpack/test/browser/deploy-url_spec_large.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ describe('Browser Builder deploy url', () => {
2424
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
2525
tap(() => {
2626
const fileName = join(outputPath, 'index.html');
27-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
27+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
2828
expect(content).toContain('deployUrl/main.js');
2929
}),
3030
concatMap(() => runTargetSpec(host, browserTargetSpec,
3131
{ deployUrl: 'http://example.com/some/path/' })),
3232
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
3333
tap(() => {
3434
const fileName = join(outputPath, 'index.html');
35-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
35+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
3636
expect(content).toContain('http://example.com/some/path/main.js');
3737
}),
3838
).subscribe(undefined, done.fail, done);
@@ -45,7 +45,7 @@ describe('Browser Builder deploy url', () => {
4545
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
4646
tap(() => {
4747
const fileName = join(outputPath, 'runtime.js');
48-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
48+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
4949
expect(content).toContain('deployUrl/');
5050
}),
5151
).subscribe(undefined, done.fail, done);

packages/angular_devkit/build_webpack/test/browser/file-replacements_spec_large.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// concatMap(() => architect.run(architect.getTarget({ overrides }))),
3333
// tap(() => {
3434
// const fileName = join(outputPath, 'main.js');
35-
// const content = virtualFs.fileBufferToString(host.asSync().read(fileName));
35+
// const content = virtualFs.fileBufferToString(host.scopedSync().read(fileName));
3636
// expect(content).toContain('production: true');
3737
// }),
3838
// ).subscribe(undefined, done.fail, done);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('Browser Builder i18n', () => {
5757
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
5858
tap(() => {
5959
const fileName = join(outputPath, 'main.js');
60-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
60+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
6161
expect(content).toMatch(/Bonjour i18n!/);
6262
}),
6363
).subscribe(undefined, done.fail, done);
@@ -79,7 +79,7 @@ describe('Browser Builder i18n', () => {
7979
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
8080
tap(() => {
8181
const fileName = join(outputPath, 'main.js');
82-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
82+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
8383
expect(content).toMatch(/Other content/);
8484
}),
8585
).subscribe(undefined, done.fail, done);
@@ -109,7 +109,7 @@ describe('Browser Builder i18n', () => {
109109
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
110110
tap(() => {
111111
const fileName = join(outputPath, 'main.js');
112-
const content = virtualFs.fileBufferToString(host.asSync().read(normalize(fileName)));
112+
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
113113
expect(content).toMatch(/registerLocaleData/);
114114
expect(content).toMatch(/angular_common_locales_fr/);
115115
}),

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ describe('Browser Builder lazy modules', () => {
8282

8383
runTargetSpec(host, browserTargetSpec).pipe(
8484
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
85-
tap(() => expect(host.asSync().exists(join(outputPath, 'lazy-lazy-module.js'))).toBe(true)),
85+
tap(() => {
86+
expect(host.scopedSync().exists(join(outputPath, 'lazy-lazy-module.js'))).toBe(true);
87+
}),
8688
).subscribe(undefined, done.fail, done);
8789
}, 30000);
8890

@@ -96,7 +98,7 @@ describe('Browser Builder lazy modules', () => {
9698

9799
runTargetSpec(host, browserTargetSpec).pipe(
98100
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
99-
tap(() => expect(host.asSync().exists(join(outputPath, '0.js'))).toBe(true)),
101+
tap(() => expect(host.scopedSync().exists(join(outputPath, '0.js'))).toBe(true)),
100102
).subscribe(undefined, done.fail, done);
101103
}, 30000);
102104

@@ -112,7 +114,7 @@ describe('Browser Builder lazy modules', () => {
112114

113115
runTargetSpec(host, browserTargetSpec).pipe(
114116
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
115-
tap(() => expect(host.asSync().exists(join(outputPath, 'lazy-module.js'))).toBe(true)),
117+
tap(() => expect(host.scopedSync().exists(join(outputPath, 'lazy-module.js'))).toBe(true)),
116118
).subscribe(undefined, done.fail, done);
117119
}, 30000);
118120

@@ -124,7 +126,7 @@ describe('Browser Builder lazy modules', () => {
124126

125127
runTargetSpec(host, browserTargetSpec).pipe(
126128
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
127-
tap(() => expect(host.asSync().exists(join(outputPath, '0.js'))).toBe(true)),
129+
tap(() => expect(host.scopedSync().exists(join(outputPath, '0.js'))).toBe(true)),
128130
).subscribe(undefined, done.fail, done);
129131
}, 30000);
130132

@@ -139,7 +141,7 @@ describe('Browser Builder lazy modules', () => {
139141

140142
runTargetSpec(host, browserTargetSpec, overrides).pipe(
141143
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
142-
tap(() => expect(host.asSync().exists(join(outputPath, '0.js'))).toBe(true)),
144+
tap(() => expect(host.scopedSync().exists(join(outputPath, '0.js'))).toBe(true)),
143145
).subscribe(undefined, done.fail, done);
144146
}, 30000);
145147

@@ -153,10 +155,10 @@ describe('Browser Builder lazy modules', () => {
153155

154156
runTargetSpec(host, browserTargetSpec).pipe(
155157
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
156-
tap(() => expect(host.asSync().exists(join(outputPath, '0.js'))).toBe(true)),
157-
tap(() => expect(host.asSync().exists(join(outputPath, '1.js'))).toBe(true)),
158+
tap(() => expect(host.scopedSync().exists(join(outputPath, '0.js'))).toBe(true)),
159+
tap(() => expect(host.scopedSync().exists(join(outputPath, '1.js'))).toBe(true)),
158160
// TODO: the chunk with common modules used to be called `common`, see why that changed.
159-
tap(() => expect(host.asSync().exists(join(outputPath, '2.js'))).toBe(true)),
161+
tap(() => expect(host.scopedSync().exists(join(outputPath, '2.js'))).toBe(true)),
160162
).subscribe(undefined, done.fail, done);
161163
}, 30000);
162164

@@ -172,9 +174,9 @@ describe('Browser Builder lazy modules', () => {
172174

173175
runTargetSpec(host, browserTargetSpec, overrides).pipe(
174176
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
175-
tap(() => expect(host.asSync().exists(join(outputPath, '0.js'))).toBe(true)),
176-
tap(() => expect(host.asSync().exists(join(outputPath, '1.js'))).toBe(true)),
177-
tap(() => expect(host.asSync().exists(join(outputPath, '2.js'))).toBe(false)),
177+
tap(() => expect(host.scopedSync().exists(join(outputPath, '0.js'))).toBe(true)),
178+
tap(() => expect(host.scopedSync().exists(join(outputPath, '1.js'))).toBe(true)),
179+
tap(() => expect(host.scopedSync().exists(join(outputPath, '2.js'))).toBe(false)),
178180
).subscribe(undefined, done.fail, done);
179181
}, 30000);
180182

@@ -205,7 +207,7 @@ describe('Browser Builder lazy modules', () => {
205207

206208
runTargetSpec(host, browserTargetSpec, overrides).pipe(
207209
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
208-
tap(() => expect(host.asSync().exists(join(outputPath, 'lazy-lazy-module.js')))
210+
tap(() => expect(host.scopedSync().exists(join(outputPath, 'lazy-lazy-module.js')))
209211
.toBe(true)),
210212
).subscribe(undefined, done.fail, done);
211213
}, 30000);

0 commit comments

Comments
 (0)