Skip to content

Commit 9c1c43b

Browse files
yjaaidijkrems
authored andcommitted
test(@angular-devkit/build-angular): add test to make sure aot is disabled by default
1 parent aa634f9 commit 9c1c43b

File tree

1 file changed

+23
-27
lines changed
  • packages/angular_devkit/build_angular/src/builders/karma/tests/options

1 file changed

+23
-27
lines changed

packages/angular_devkit/build_angular/src/builders/karma/tests/options/aot_spec.ts

+23-27
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import { execute } from '../../index';
1010
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup';
1111
import { BuilderMode } from '../../schema';
1212

13-
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
13+
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isApplicationBuilder) => {
1414
describe('Option: "aot"', () => {
15-
it('enables aot with application builder', async () => {
15+
it('enables aot', async () => {
1616
await setupTarget(harness);
1717

1818
await harness.writeFiles({
1919
'src/aot.spec.ts': `
2020
import { Component } from '@angular/core';
21-
21+
2222
describe('Hello', () => {
2323
it('should *not* contain jit instructions', () => {
2424
@Component({
@@ -32,48 +32,44 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
3232
`,
3333
});
3434

35-
harness.useTarget('test', {
36-
...BASE_OPTIONS,
37-
aot: true,
38-
/** Cf. {@link ../builder-mode_spec.ts} */
39-
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
40-
builderMode: BuilderMode.Application,
41-
});
42-
43-
const { result } = await harness.executeOnce();
44-
expect(result?.success).toBeTrue();
35+
expect(await runTest({ aot: true })).toBeTrue();
4536
});
4637

47-
it('enables aot with browser builder', async () => {
38+
it('is turned off by default', async () => {
4839
await setupTarget(harness);
4940

5041
await harness.writeFiles({
5142
'src/aot.spec.ts': `
5243
import { Component } from '@angular/core';
53-
44+
5445
describe('Hello', () => {
55-
it('should *not* contain jit instructions', () => {
46+
it('should contain jit instructions', () => {
5647
@Component({
5748
template: 'Hello',
5849
})
5950
class Hello {}
6051
61-
expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit');
52+
expect((Hello as any).ɵcmp.template.toString()).toContain('jit');
6253
});
6354
});
6455
`,
6556
});
6657

67-
harness.useTarget('test', {
68-
...BASE_OPTIONS,
69-
aot: true,
70-
/** Cf. {@link ../builder-mode_spec.ts} */
71-
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
72-
builderMode: BuilderMode.Browser,
73-
});
74-
75-
const { result } = await harness.executeOnce();
76-
expect(result?.success).toBeTrue();
58+
expect(await runTest()).toBeTrue();
7759
});
7860
});
61+
62+
async function runTest({ aot }: { aot?: boolean } = {}) {
63+
harness.useTarget('test', {
64+
...BASE_OPTIONS,
65+
aot,
66+
/** Cf. {@link ../builder-mode_spec.ts} */
67+
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'],
68+
builderMode: isApplicationBuilder ? BuilderMode.Application : BuilderMode.Browser,
69+
});
70+
71+
const { result } = await harness.executeOnce();
72+
73+
return result?.success;
74+
}
7975
});

0 commit comments

Comments
 (0)