|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
| 8 | +import { describeBuilder } from '../../testing'; |
| 9 | +import { buildWebpackBrowser } from '../index'; |
8 | 10 |
|
9 |
| -import { Architect } from '@angular-devkit/architect'; |
10 |
| -import { normalize } from '@angular-devkit/core'; |
11 |
| -import { browserBuild, createArchitect, host } from '../../test-utils'; |
| 11 | +const BROWSER_BUILDER_INFO = { |
| 12 | + name: '@angular-devkit/build-angular:browser', |
| 13 | + schemaPath: __dirname + '/../schema.json', |
| 14 | +}; |
12 | 15 |
|
| 16 | +describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { |
| 17 | + describe('basic test', () => { |
| 18 | + it('works', async () => { |
| 19 | + // Provide a target and options for builder execution |
| 20 | + harness.useTarget('build', { |
| 21 | + outputPath: 'dist', |
| 22 | + index: 'src/index.html', |
| 23 | + main: 'src/main.ts', |
| 24 | + polyfills: 'src/polyfills.ts', |
| 25 | + tsConfig: 'src/tsconfig.app.json', |
| 26 | + progress: false, |
| 27 | + assets: ['src/favicon.ico', 'src/assets'], |
| 28 | + styles: ['src/styles.css'], |
| 29 | + scripts: [], |
| 30 | + }); |
13 | 31 |
|
14 |
| -describe('Browser Builder basic test', () => { |
15 |
| - const target = { project: 'app', target: 'build' }; |
16 |
| - let architect: Architect; |
| 32 | + // Execute builder with above provided project, target, and options |
| 33 | + await harness.executeOnce(); |
17 | 34 |
|
18 |
| - beforeEach(async () => { |
19 |
| - await host.initialize().toPromise(); |
20 |
| - architect = (await createArchitect(host.root())).architect; |
21 |
| - }); |
22 |
| - |
23 |
| - afterEach(async () => host.restore().toPromise()); |
24 |
| - |
25 |
| - it('works', async () => { |
26 |
| - await browserBuild(architect, host, target); |
27 |
| - |
28 |
| - // Default files should be in outputPath. |
29 |
| - expect(await host.scopedSync().exists(normalize('dist/runtime.js'))).toBe(true); |
30 |
| - expect(await host.scopedSync().exists(normalize('dist/main.js'))).toBe(true); |
31 |
| - expect(await host.scopedSync().exists(normalize('dist/polyfills.js'))).toBe(true); |
32 |
| - expect(await host.scopedSync().exists(normalize('dist/vendor.js'))).toBe(true); |
33 |
| - expect(await host.scopedSync().exists(normalize('dist/favicon.ico'))).toBe(true); |
34 |
| - expect(await host.scopedSync().exists(normalize('dist/styles.css'))).toBe(true); |
35 |
| - expect(await host.scopedSync().exists(normalize('dist/index.html'))).toBe(true); |
| 35 | + // Default files should be in outputPath. |
| 36 | + expect(harness.hasFile('dist/runtime.js')).toBe(true); |
| 37 | + expect(harness.hasFile('dist/main.js')).toBe(true); |
| 38 | + expect(harness.hasFile('dist/polyfills.js')).toBe(true); |
| 39 | + expect(harness.hasFile('dist/vendor.js')).toBe(true); |
| 40 | + expect(harness.hasFile('dist/favicon.ico')).toBe(true); |
| 41 | + expect(harness.hasFile('dist/styles.css')).toBe(true); |
| 42 | + expect(harness.hasFile('dist/index.html')).toBe(true); |
| 43 | + }); |
36 | 44 | });
|
37 | 45 | });
|
0 commit comments