pact-foundation / karma-pact

Pact Framework Plugin for Karma
http://docs.pact.io/
Other
10 stars 9 forks source link

Failed to Remove Pact Server after update to Angular 14 #37

Closed kapenzo closed 11 months ago

kapenzo commented 2 years ago

Hello, we have an Angular application which we updated from ver. 13 to 14. It looks like after running 'npm run test' the mock server is not beeing killed and the prozess cannot be finished.

We have the following console logs at the end:

Chrome Headless 101.0.4951.64 (Windows 10): Executed 158 of 158 SUCCESS (0 secs / 10.189 secs) Chrome Headless 101.0.4951.64 (Windows 10): Executed 158 of 158 SUCCESS (51.854 secs / 10.189 secs) 21 06 2022 16:00:23.174:DEBUG [launcher]: CAPTURED -> BEING_KILLED 21 06 2022 16:00:23.175:DEBUG [launcher]: BEING_KILLED -> BEING_FORCE_KILLED 21 06 2022 16:00:23.175:DEBUG [Chrome Headless 101.0.4951.64 (Windows 10)]: CONNECTED -> DISCONNECTED TOTAL: 158 SUCCESS TOTAL: 158 SUCCESS 21 06 2022 16:00:23.179:DEBUG [karma-server]: Run complete, exiting. 21 06 2022 16:00:23.180:DEBUG [launcher]: Disconnecting all browsers 21 06 2022 16:00:23.181:DEBUG [launcher]: BEING_FORCE_KILLED -> BEING_FORCE_KILLED 21 06 2022 16:00:23.184:DEBUG [proxy]: Destroying proxy agents 21 06 2022 16:00:23.202:DEBUG [launcher]: Process ChromeHeadless exited with code null and signal SIGTERM 21 06 2022 16:00:23.203:DEBUG [temp-dir]: Cleaning temp dir C:\Soft\VSCode-win32-x64-1.66.2\data\tmp\karma-7291136 [2022-06-21 14:00:23.205 +0000] DEBUG: pact-node@10.17.1: ERROR Errno::ECONNRESET: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. @ io_fillbuf - fd:5 C:/app/node_modules/@pact-foundation/pact-node/standalone/win32-1.88.81/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:in eof?' C:/app/node_modules/@pact-foundation/pact-node/standalone/win32-1.88.81/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:80:inrun' C:/app/node_modules/@pact-foundation/pact-node/standalone/win32-1.88.81/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/server.rb:191:in `block in start_thread'

21 06 2022 16:00:23.240:DEBUG [launcher]: Finished all browsers 21 06 2022 16:00:23.241:DEBUG [launcher]: BEING_FORCE_KILLED -> FINISHED 21 06 2022 16:00:23.241:DEBUG [launcher]: FINISHED -> FINISHED 21 06 2022 16:00:23.245:DEBUG [karma-server]: Received stop event, exiting. 21 06 2022 16:00:23.245:DEBUG [launcher]: Disconnecting all browsers 21 06 2022 16:00:23.245:DEBUG [launcher]: FINISHED -> BEING_FORCE_KILLED 21 06 2022 16:00:23.246:DEBUG [proxy]: Destroying proxy agents

Our package.json: "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^14.0.2", "@angular/cdk": "^14.0.2", "@angular/common": "^14.0.2", "@angular/compiler": "^14.0.2", "@angular/core": "^14.0.2", "@angular/forms": "^14.0.2", "@angular/material": "^14.0.2", "@angular/platform-browser": "^14.0.2", "@angular/platform-browser-dynamic": "^14.0.2", "@angular/router": "^14.0.2", "concurrently": "~7.2.2", "rxjs": "~7.5.5", "tslib": "~2.4.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^14.0.2", "@angular/cli": "^14.0.2", "@angular/compiler-cli": "^14.0.2", "@pact-foundation/karma-pact": "3.1.0", "@pact-foundation/pact-node": "10.17.1", "@pact-foundation/pact-web": "9.17.2", "@types/jasmine": "~3.6.0", "@types/jasminewd2": "~2.0.3", "@types/node": "~14.14.31", "codelyzer": "~6.0.0", "jasmine-core": "~3.8.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "~1.7.0", "protractor": "~7.0.0", "schematics-scss-migrate": "1.3.14", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~4.6.4" }, "config": { "pact_do_not_track": true }

If you give me instruction how to debug the karma-pact or see some logs I can look for the reason of the bug.

CynanX commented 2 years ago

I am also seeing this issue. Anything I can do to assist let me know.

YOU54F commented 2 years ago

@kapenzo

Karma-pact uses pact-js-core, this is taken from this projects's readme

All options are passed directly into Pact Node, which has the full list of available options

in which you can set the required logLevel you wish, within the pact key in your karma config

@CynanX

Hope that helps in trying to identify the root cause and if we need to update something in a Pact project we can

CynanX commented 2 years ago

I saw that pact-web has dropped support for karma-pact, so I've worked around this now removing karma-pact, starting up the mock server before I run the tests and then stopping the server using the pact cli.

MrMightyNighty commented 2 years ago

We also have issues with Angular 14 and Pact.

I saw that pact-web has dropped support for karma-pact, so I've worked around this now removing karma-pact, starting up the mock server before I run the tests and then stopping the server using the pact cli.

Do you have a good example for using the CLI? I'm reading through the Pact docs but they aren't very helpful and the CLI commands don't match with the docs

CynanX commented 2 years ago

We also have issues with Angular 14 and Pact.

I saw that pact-web has dropped support for karma-pact, so I've worked around this now removing karma-pact, starting up the mock server before I run the tests and then stopping the server using the pact cli.

Do you have a good example for using the CLI? I'm reading through the Pact docs but they aren't very helpful and the CLI commands don't match with the docs

This is what I am doing at the moment, though the latest pact-web is now also failing so I'm going to look at moving over to JEST instead in the long term.

./node_modules/@pact-foundation/pact-node/bin/pact-mock-service.js start --consumer=ui --provider=server --port 1234 --host localhost --pact-dir=./ui/pacts --pact-file-write-mode=overwrite --log ./ui/logs/mockserver-integration.log --pact-specification-version=2 --cors=CORS --no-ssl

./node_modules/@angular/cli/bin/ng.js test --include src/app/api-pacts/ --watch=false --browsers=ChromeHeadless

./node_modules/@pact-foundation/pact-node/bin/pact-mock-service.js stop
alexpalacean commented 2 years ago

Hi, we have the same issue after upgrading to Angular 14. Is there some solution to stop the process after the tests are finished running?

olaru-raul commented 2 years ago

Hello,

We also have the same issue after upgradint to ng14, and we didn't find a workaround to stop the process yet.

RedayY commented 1 year ago

Hi just to update I also stumbled into this same exact issue at work 🤷 without any solution. Did anyone found a workaround for this?

korjikk commented 1 year ago

Hi just to update I also stumbled into this same exact issue at work 🤷 without any solution. Did anyone found a workaround for this?

Our solution was to switch to Jest as pact tests runner.

RedayY commented 1 year ago

Our solution was to switch to Jest as pact tests runner.

tysm for the reply! :) I will take a look if this is possible for us

almai commented 1 year ago

Hi *,

we have 3 older Angular v13 frontends that where implemented using karma/jasmine. When I tried to update them to v14 last year I ran into the problems described above.

Since we have thousands of tests, switching to jest is not an option. So my question is, if anybody has managed to make pact-js run with karma/jasmine and Angular >= v14 (locally and on Jenkins)?