Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

BrowserStack: Karma tests hang after finish with Angular 14 #195

Open
suryart opened this issue Jul 28, 2022 · 7 comments
Open

BrowserStack: Karma tests hang after finish with Angular 14 #195

suryart opened this issue Jul 28, 2022 · 7 comments

Comments

@suryart
Copy link

suryart commented Jul 28, 2022

Description

For Angular 14, when running the unit tests with Karma the process hangs after all tests finish successfully. As I can see the test getting completed on BrowserStack. Here is a session public link.

Here is an example repository created by @daniel-sc where issue can be reproduced.

Details for setting up and running the tests are in the example repository(link above).

Here is the link to log file.

What is happening?

When running the npm run test-ci the process is stuck after 28 07 2022 18:24:35.692:DEBUG [launcher]: FINISHED -> FINISHED log line.

What is expected?

When the tests are finished the process should exit.

@ravasconcelos
Copy link

Hi,

I am experiencing exactly the same issue in my project after upgrading it to Angular 14. It was working fine on Angular 12.

@suryart , if you find any work around, can you please share it?

@daniel-sc
Copy link

daniel-sc commented Aug 4, 2022

A (hacky) workaround is to run the following before executing the tests:

sed -i -z "s/ removeAllListeners()\n/ removeAllListeners();process.nextTick(() => process.exit(code || 0));\n/g" node_modules/karma/lib/server.js

Hope this helps others that get stuck..

@ravasconcelos
Copy link

Thank you for sharing the hack @daniel-sc it worked for me with a minor adjustment!

@Blackbaud-SteveBrush
Copy link

So is this a fix that needs to happen in karma-browserstack-launcher or karma, or...?

@simon-chen-1
Copy link

simon-chen-1 commented Jan 11, 2023

@daniel-sc Running that before executing the tests worked perfectly! But I'm curious if there's an alternative solution/fix in place that would resolve this issue without having to run that script you shared?

@daniel-sc
Copy link

I'm not aware of any real solution to this issue. It seems that nobody at Browserstack really cares about this.. 🤷‍♀️

@MessiasLima
Copy link

A (hacky) workaround is to run the following before executing the tests:

sed -i -z "s/ removeAllListeners()\n/ removeAllListeners();process.nextTick(() => process.exit(code || 0));\n/g" node_modules/karma/lib/server.js

Hope this helps others that get stuck..

Thank you @daniel-sc I'm trying to use patch-package to apply your solution. So, should the code looks like this?

Screenshot 2023-02-20 at 21 01 45

Deminder added a commit to Deminder/LocalChat that referenced this issue May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants