Skip to content

Commit 7447211

Browse files
committed
test: Reduce default timeouts
The default 2.5-minute timeout is often unnecessary and can interfere with test execution. Specifically, Bazel may terminate the test before Jasmine does, making it harder to identify which test is causing the issue.
1 parent bfbef6e commit 7447211

File tree

5 files changed

+51
-25
lines changed

5 files changed

+51
-25
lines changed

modules/testing/builder/src/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import {
2424
import path from 'node:path';
2525
import { firstValueFrom } from 'rxjs';
2626

27-
// Default timeout for large specs is 2.5 minutes.
28-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;
27+
// Default timeout for large specs is 60s.
28+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60_000;
2929

3030
export const workspaceRoot = join(normalize(__dirname), `../projects/hello-world-app/`);
3131
export const host = new TestProjectHost(workspaceRoot);

packages/angular/build/src/builders/application/tests/options/output-path_spec.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ import { buildApplication } from '../../index';
1010
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup';
1111

1212
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
13-
beforeEach(async () => {
14-
// Add a global stylesheet media file
15-
await harness.writeFile('src/styles.css', `h1 { background: url('./spectrum.png')}`);
16-
// Add a component stylesheet media file
17-
await harness.writeFile('src/app/abc.svg', '');
18-
await harness.writeFile('src/app/app.component.css', `h2 { background: url('./abc.svg')}`);
19-
20-
// Enable SSR
21-
await harness.modifyFile('src/tsconfig.app.json', (content) => {
22-
const tsConfig = JSON.parse(content);
23-
tsConfig.files ??= [];
24-
tsConfig.files.push('main.server.ts', 'server.ts');
25-
26-
return JSON.stringify(tsConfig);
27-
});
13+
describe('Option: "outputPath"', () => {
14+
beforeEach(async () => {
15+
// Add a global stylesheet media file
16+
await harness.writeFile('src/styles.css', `h1 { background: url('./spectrum.png')}`);
17+
// Add a component stylesheet media file
18+
await harness.writeFile('src/app/abc.svg', '');
19+
await harness.writeFile('src/app/app.component.css', `h2 { background: url('./abc.svg')}`);
20+
21+
// Enable SSR
22+
await harness.modifyFile('src/tsconfig.app.json', (content) => {
23+
const tsConfig = JSON.parse(content);
24+
tsConfig.files ??= [];
25+
tsConfig.files.push('main.server.ts', 'server.ts');
26+
27+
return JSON.stringify(tsConfig);
28+
});
2829

29-
// Application server code is not needed in this test
30-
await harness.writeFile('src/main.server.ts', `console.log('Hello!');`);
31-
await harness.writeFile('src/server.ts', `console.log('Hello!');`);
32-
});
30+
// Application server code is not needed in this test
31+
await harness.writeFile('src/main.server.ts', `console.log('Hello!');`);
32+
await harness.writeFile('src/server.ts', `console.log('Hello!');`);
33+
});
3334

34-
describe('Option: "outputPath"', () => {
3535
describe(`when option value is is a string`, () => {
3636
beforeEach(() => {
3737
harness.useTarget('build', {

packages/angular_devkit/build_angular/src/builders/app-shell/app-shell_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ import { createArchitect, host } from '../../testing/test-utils';
1313
describe('AppShell Builder', () => {
1414
const target = { project: 'app', target: 'app-shell' };
1515
let architect: Architect;
16+
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
17+
18+
beforeAll(() => {
19+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100_000;
20+
});
21+
22+
afterAll(() => {
23+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
24+
});
1625

1726
beforeEach(async () => {
1827
await host.initialize().toPromise();

packages/angular_devkit/build_angular/src/builders/ng-packagr/works_spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ import {
1919
} from '@angular-devkit/core';
2020
import { debounceTime, map, take, tap } from 'rxjs';
2121

22-
// Default timeout for large specs is 2.5 minutes.
23-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;
24-
2522
describe('NgPackagr Builder', () => {
2623
const workspaceRoot = join(normalize(__dirname), `../../../test/hello-world-lib/`);
2724
const host = new TestProjectHost(workspaceRoot);
2825
let architect: Architect;
2926

27+
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
28+
29+
beforeAll(() => {
30+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 80_000;
31+
});
32+
33+
afterAll(() => {
34+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
35+
});
36+
3037
beforeEach(async () => {
3138
await host.initialize().toPromise();
3239

packages/angular_devkit/build_angular/src/builders/prerender/works_spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import { join, normalize, virtualFs } from '@angular-devkit/core';
1111
import { createArchitect, host } from '../../testing/test-utils';
1212

1313
describe('Prerender Builder', () => {
14+
const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
15+
16+
beforeAll(() => {
17+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100_000;
18+
});
19+
20+
afterAll(() => {
21+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
22+
});
23+
1424
const target = { project: 'app', target: 'prerender' };
1525
let architect: Architect;
1626

0 commit comments

Comments
 (0)