mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 20:52:06 +08:00
test: remove browser builder AOT tests
These cases are covered in other spec files.
This commit is contained in:
parent
4d88743b02
commit
b78ccb073a
@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright Google LLC All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by an MIT-style license that can be
|
|
||||||
* found in the LICENSE file at https://angular.dev/license
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Architect } from '@angular-devkit/architect';
|
|
||||||
import { BrowserBuilderOutput } from '@angular-devkit/build-angular';
|
|
||||||
import { join, logging, normalize, virtualFs } from '@angular-devkit/core';
|
|
||||||
import { lastValueFrom } from 'rxjs';
|
|
||||||
import { createArchitect, host } from '../../../testing/test-utils';
|
|
||||||
|
|
||||||
describe('Browser Builder AOT', () => {
|
|
||||||
const targetSpec = { project: 'app', target: 'build' };
|
|
||||||
let architect: Architect;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await host.initialize().toPromise();
|
|
||||||
architect = (await createArchitect(host.root())).architect;
|
|
||||||
});
|
|
||||||
afterEach(async () => host.restore().toPromise());
|
|
||||||
|
|
||||||
it('works', async () => {
|
|
||||||
const overrides = { aot: true };
|
|
||||||
|
|
||||||
const run = await architect.scheduleTarget(targetSpec, overrides);
|
|
||||||
const output = (await run.result) as BrowserBuilderOutput;
|
|
||||||
|
|
||||||
expect(output.success).toBeTrue();
|
|
||||||
|
|
||||||
const fileName = join(normalize(output.outputs[0].path), 'main.js');
|
|
||||||
const content = virtualFs.fileBufferToString(
|
|
||||||
await lastValueFrom(host.read(normalize(fileName))),
|
|
||||||
);
|
|
||||||
expect(content).toContain('AppComponent_Factory');
|
|
||||||
|
|
||||||
await run.stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows error when component stylesheet contains SCSS syntax error', async () => {
|
|
||||||
const overrides = {
|
|
||||||
aot: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
host.replaceInFile('src/app/app.component.ts', 'app.component.css', 'app.component.scss');
|
|
||||||
|
|
||||||
host.writeMultipleFiles({
|
|
||||||
'src/app/app.component.scss': `
|
|
||||||
.foo {
|
|
||||||
`,
|
|
||||||
});
|
|
||||||
|
|
||||||
const logger = new logging.Logger('');
|
|
||||||
const logs: string[] = [];
|
|
||||||
logger.subscribe((e) => logs.push(e.message));
|
|
||||||
|
|
||||||
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
|
|
||||||
const output = await run.result;
|
|
||||||
expect(output.success).toBe(false);
|
|
||||||
expect(logs.join()).toContain('expected "}".');
|
|
||||||
await run.stop();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright Google LLC All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by an MIT-style license that can be
|
|
||||||
* found in the LICENSE file at https://angular.dev/license
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Architect } from '@angular-devkit/architect';
|
|
||||||
import { browserBuild, createArchitect, host } from '../../../testing/test-utils';
|
|
||||||
|
|
||||||
describe('Browser Builder no entry module', () => {
|
|
||||||
const target = { project: 'app', target: 'build' };
|
|
||||||
let architect: Architect;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await host.initialize().toPromise();
|
|
||||||
architect = (await createArchitect(host.root())).architect;
|
|
||||||
});
|
|
||||||
afterEach(async () => host.restore().toPromise());
|
|
||||||
|
|
||||||
it('works', async () => {
|
|
||||||
// Remove the bootstrap but keep a reference to AppModule so the import is not elided.
|
|
||||||
host.replaceInFile('src/main.ts', /platformBrowserDynamic.*?bootstrapModule.*?;/, '');
|
|
||||||
host.appendToFile('src/main.ts', 'console.log(AppModule);');
|
|
||||||
|
|
||||||
await browserBuild(architect, host, target, { baseHref: '/myUrl' });
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user