angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.74k stars 11.98k forks source link

Tests using `web-test-runner` time out waiting for the browser to start #27447

Open OBe95 opened 5 months ago

OBe95 commented 5 months ago

Command

test

Is this a regression?

The previous version in which this bug was not present was

No response

Description

We are concerned about Karma not being maintained and we want to know the cost of migrating to other alternatives

We came across your blog post Moving Angular CLI to Jest and Web Test Runner and want to explore the web-test-runner, but it fails with the following error: The browser was unable to create and start a test page after 30000ms. You can increase this timeout with the browserStartTimeout option.

image

Minimal Reproduction

I started a new project:

Exception or Error

No response

Your Environment

Angular CLI: 17.3.3
Node: 20.11.0
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 17.3.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.3
@angular-devkit/build-angular   17.3.3
@angular-devkit/core            17.3.3
@angular-devkit/schematics      17.3.3
@schematics/angular             17.3.3
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.4

Anything else relevant?

No response

abderrahmane-hilali commented 4 months ago

just install @web/test-runner-core and it will work.

I think it should be added to the error message

berkon commented 3 months ago

Unfortunately installing @web/test-runner-core didn't help.

OBe95 commented 3 months ago

Normally @web/test-runner-core is already a dependency of test-web-runner

jahorton commented 3 months ago

What sort of browser-launcher setup are you using when running your tests? Are you trying to test against an older set of browsers, by chance?

Apologies if this ends up being unrelated, but I ran into this issue (and error message) while trying to resolve my own; perhaps notes I left at https://github.com/modernweb-dev/web/issues/2756 might help.

terrycoughlan commented 2 months ago

Add this to your angular.json file to get the tests passing for now image

berkon commented 2 months ago

Correct, I found this too. Looks like this is required starting with Angular 15.