Skip to content

Commit dc829be

Browse files
committed
test: remove no longer needed delay in code coverage tests
This should no longer needed as the root issue has been addressed upstream.
1 parent eaeef05 commit dc829be

3 files changed

Lines changed: 2 additions & 41 deletions

File tree

packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/code-coverage_spec.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,9 @@
88

99
import { tags } from '@angular-devkit/core';
1010
import { last, tap } from 'rxjs/operators';
11-
import { promisify } from 'util';
1211
import { execute } from '../../index';
1312
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeBuilder } from '../setup';
1413

15-
// In each of the test below we'll have to call setTimeout to wait for the coverage
16-
// analysis to be done. This is because karma-coverage performs the analysis
17-
// asynchronously but the promise that it returns is not awaited by Karma.
18-
// Coverage analysis begins when onRunComplete() is invoked, and output files
19-
// are subsequently written to disk. For more information, see
20-
// https://github.com/karma-runner/karma-coverage/blob/32acafa90ed621abd1df730edb44ae55a4009c2c/lib/reporter.js#L221
21-
22-
const setTimeoutPromise = promisify(setTimeout);
2314
const coveragePath = 'coverage/lcov.info';
2415

2516
describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
@@ -36,7 +27,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
3627
const { result } = await harness.executeOnce();
3728
expect(result?.success).toBeTrue();
3829

39-
await setTimeoutPromise(1000);
4030
harness.expectFile(coveragePath).toExist();
4131
});
4232

@@ -95,7 +85,7 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
9585
`title = 'app'`,
9686
tags.stripIndents`
9787
title = 'app';
98-
88+
9989
async foo() {
10090
return 'foo';
10191
}
@@ -111,8 +101,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
111101
const { result } = await harness.executeOnce();
112102
expect(result?.success).toBeTrue();
113103

114-
await setTimeoutPromise(1000);
115-
116104
harness
117105
.expectFile('coverage/app.component.ts.html')
118106
.content.toContain(

packages/angular_devkit/build_angular/src/builders/karma/tests/options/code-coverage-exclude_spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { promisify } from 'util';
109
import { execute } from '../../index';
1110
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeBuilder } from '../setup';
1211

13-
// In each of the test below we'll have to call setTimeout to wait for the coverage
14-
// analysis to be done. This is because karma-coverage performs the analysis
15-
// asynchronously but the promise that it returns is not awaited by Karma.
16-
// Coverage analysis begins when onRunComplete() is invoked, and output files
17-
// are subsequently written to disk. For more information, see
18-
// https://github.com/karma-runner/karma-coverage/blob/32acafa90ed621abd1df730edb44ae55a4009c2c/lib/reporter.js#L221
19-
20-
const setTimeoutPromise = promisify(setTimeout);
2112
const coveragePath = 'coverage/lcov.info';
2213

2314
describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
@@ -33,7 +24,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
3324

3425
expect(result?.success).toBeTrue();
3526

36-
await setTimeoutPromise(1000);
3727
harness.expectFile(coveragePath).content.not.toContain('app.component.ts');
3828
});
3929

@@ -48,7 +38,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
4838

4939
expect(result?.success).toBeTrue();
5040

51-
await setTimeoutPromise(1000);
5241
harness.expectFile(coveragePath).content.not.toContain('app.component.ts');
5342
});
5443

@@ -62,7 +51,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
6251

6352
expect(result?.success).toBeTrue();
6453

65-
await setTimeoutPromise(1000);
6654
harness.expectFile(coveragePath).content.toContain('app.component.ts');
6755
});
6856
});

packages/angular_devkit/build_angular/src/builders/karma/tests/options/code-coverage_spec.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { promisify } from 'util';
109
import { execute } from '../../index';
1110
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeBuilder } from '../setup';
1211

13-
// In each of the test below we'll have to call setTimeout to wait for the coverage
14-
// analysis to be done. This is because karma-coverage performs the analysis
15-
// asynchronously but the promise that it returns is not awaited by Karma.
16-
// Coverage analysis begins when onRunComplete() is invoked, and output files
17-
// are subsequently written to disk. For more information, see
18-
// https://github.com/karma-runner/karma-coverage/blob/32acafa90ed621abd1df730edb44ae55a4009c2c/lib/reporter.js#L221
19-
20-
const setTimeoutPromise = promisify(setTimeout);
2112
const coveragePath = 'coverage/lcov.info';
2213

2314
describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
@@ -31,7 +22,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
3122
const { result } = await harness.executeOnce();
3223
expect(result?.success).toBeTrue();
3324

34-
await setTimeoutPromise(1000);
3525
harness.expectFile(coveragePath).toExist();
3626
});
3727

@@ -44,8 +34,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
4434
const { result } = await harness.executeOnce();
4535

4636
expect(result?.success).toBeTrue();
47-
48-
await setTimeoutPromise(1000);
4937
harness.expectFile(coveragePath).toNotExist();
5038
});
5139

@@ -57,8 +45,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
5745
const { result } = await harness.executeOnce();
5846

5947
expect(result?.success).toBeTrue();
60-
61-
await setTimeoutPromise(1000);
6248
harness.expectFile(coveragePath).toNotExist();
6349
});
6450

@@ -73,7 +59,7 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
7359
'./src/app/app.component.ts': `
7460
import { Component } from '@angular/core';
7561
import { title } from 'my-lib';
76-
62+
7763
@Component({
7864
selector: 'app-root',
7965
templateUrl: './app.component.html',
@@ -105,7 +91,6 @@ describeBuilder(execute, KARMA_BUILDER_INFO, (harness) => {
10591
const { result } = await harness.executeOnce();
10692
expect(result?.success).toBeTrue();
10793

108-
await setTimeoutPromise(1000);
10994
harness.expectFile(coveragePath).content.not.toContain('my-lib');
11095
});
11196
});

0 commit comments

Comments
 (0)