Getting error in jenkins with test coverage after upgrading from Angular 9 to Angular14 - karma-jasmine

Can someone please point me how to debug this issue further. Get below error when jenkins job is run and the application is one Angular 14.
[32m13 10 2022 23:01:01.881:INFO [karma-server]: [39mKarma v6.4.1 server started at http://localhost:9876/
[32m13 10 2022 23:01:01.884:INFO [launcher]: [39mLaunching browsers ChromeHeadless with concurrency unlimited
[32m13 10 2022 23:01:01.887:INFO [launcher]: [39mStarting browser ChromeHeadless
[32m13 10 2022 23:01:03.202:INFO [Chrome Headless 63.0.3239.132 (Linux x86_64)]: [39mConnected on socket ajz1GfKScPy5uAgXAAAB with id 803388
Chrome Headless 63.0.3239.132 (Linux x86_64): Executed 0 of 0[32m SUCCESS[39m (0 secs / 0 secs)
[1A[2K[31mChrome Headless 63.0.3239.132 (Linux x86_64) ERROR[39m
An error was thrown in afterAll
Uncaught SyntaxError: Unexpected token {
SyntaxError: Unexpected token {
Uncaught SyntaxError: Unexpected token .
SyntaxError: Unexpected token .

Related

Timed out connecting to Chrome, giving up error - EC2 instance jenkins running selenium tests

I'm receiving the following error when trying to run my selenium tests through an ec2 instance using Jenkins.
Running the tests locally works fine.
The output of the logs:
[[1;34mINFO[m] -------------------------------------------------------
[[1;34mINFO[m] T E S T S
[[1;34mINFO[m] -------------------------------------------------------
[[1;34mINFO[m] Running [1mTestSuite[m
[main] INFO com.DefaultTest - BeforeClass start
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 106.0.5249.61 (resolved driver for Chrome 106)
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /var/lib/jenkins/.cache/selenium/chromedriver/linux64/106.0.5249.61/chromedriver
Starting ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249#{#569}) on port 42525
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Oct 11, 2022 11:13:53 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Oct 11, 2022 11:13:55 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 106, so returning the closest version found: a no-op implementation
Oct 11, 2022 11:13:55 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Unable to find CDP implementation matching 106.
Oct 11, 2022 11:13:55 PM org.openqa.selenium.chromium.ChromiumDriver lambda$new$3
WARNING: Unable to find version of CDP to use for . You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.1.3` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.
[main] INFO com.page.MainApp - URL: data:,
[main] INFO com.DefaultTest - AfterClass start
[main] INFO com.DefaultTest - BeforeClass start
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 106.0.5249.61 (resolved driver for Chrome 106)
[main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /var/lib/jenkins/.cache/selenium/chromedriver/linux64/106.0.5249.61/chromedriver
Starting ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249#{#569}) on port 50463
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1665530123.403][WARNING]: Timed out connecting to Chrome, retrying...
[1665530132.591][WARNING]: Timed out connecting to Chrome, retrying...
[1665530149.634][WARNING]: Timed out connecting to Chrome, giving up.
[1665530156.893][WARNING]: Timed out connecting to Chrome, retrying...
[1665530166.364][WARNING]: Timed out connecting to Chrome, retrying...
[1665530186.944][WARNING]: Timed out connecting to Chrome, giving up.
Build timed out (after 3 minutes). Marking the build as failed.
[[1;34mINFO[m]
[[1;34mINFO[m] Results:
[[1;34mINFO[m]
[[1;34mINFO[m] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[[1;34mINFO[m]
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 03:07 min
[[1;34mINFO[m] Finished at: 2022-10-11T23:16:40Z
I'm not sure how to resolve this.
I have google chrome and chromedriver on the same version (v106).
I've attempted adding countless arguments that people have suggested, but still can't get it to run successfully

Failed to use vscode remote ssh, but use ssh directly can work

Problem
I re-installed my server system.Before then, I can use remote-ssh normally.However, I can't use remote-ssh to connect to my server anymore.But I can still use ssh directly to connect to the server.
I suppose it managed to get into the system but somehow it broke down.
The error log is below:
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-77-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue 14 Sep 2021 09:56:58 PM CST
System load: 0.07 Processes: 117
Usage of /: 6.5% of 59.00GB Users logged in: 1
Memory usage: 10% IPv4 address for eth0: 10.0.12.2
Swap usage: 0%
* Super-optimized for small spaces - read how we shrank the memory
footprint of MicroK8s to make it the smallest full K8s around.
https://ubuntu.com/blog/microk8s-memory-optimisation
ready: 6425958cce28
Linux 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021
6425958cce28: running
bash: line 1: _exitcode: command not found
bash: line 2: syntax error near unexpected token `elif'
bash: line 2: ` elif [[ $ALLOW_CLIENT_DOWNLOAD == "1" ]]; then'
-sh: 4: function: not found
-sh: 69: [[: not found
-sh: 90: [[: not found
-sh: 155: Syntax error: "(" unexpected (expecting "then")
Transferred: sent 17180, received 4016 bytes, in 0.5 seconds
Bytes per second: sent 35433.6, received 8283.0
local-server-1> ssh child died, shutting down
[21:56:58.587] Failed to parse remote port from server output
[21:56:58.588] Resolver error: Error:
at Function.Create (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:64659)
at Object.t.handleInstallOutput (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:63302)
at Object.e [as tryInstallWithLocalServer] (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:387573)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async /Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:294473
at async Object.t.withShowDetailsEvent (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:406463)
at async /Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:386112
at async E (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:382710)
at async Object.t.resolveWithLocalServer (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:385728)
at async Object.t.resolve (/Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:1:295870)
at async /Users/luther/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.7/out/extension.js:127:110656
[21:56:58.592] ------
Tried
I tried delete the know_hosts file from host, re-install the remote-ssh plugin, but can't work
I am pretty new to remote-ssh, hope can give me more detailed solution.
Thanks :)
I downgraded remote-ssh.Then I changed my default shell into zsh and upgrade remote-ssh.It began to install '.vscode-server' file again and magically it worked.

The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

I get the following error when I run this command on headless ubuntu 20.04
selenium-side-runner -c "browserName=chrome chromeOptions.args=[disable-infobars, headless]" myproject.side
info: Running Mynew.side
FAIL MySuiteOne/MytestOne.test.js
● Test suite failed to run
WebDriverError: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
at Object.throwDecodedError (../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/error.js:550:15)
at parseHttpResponse (../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:560:13)
at Executor.execute (../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:486:26)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.255s
Ran all test suites.
My Chrome version:91.0.4472.77 installed in /usr/bin/google-chrome
Chrome driver version: chromedriver#90.0.1
I also tried commands
selenium-side-runner /path/to/your-project.side
selenium-side-runner -c "browserName=chrome chromeOptions.args=[headless, no-sandbox, disable-dev-shm-usage, disable-infobars] chromeOptions.binary='/usr/bin/google-chrome'" Mynew.side
But still, I am facing the same error. Is there any way to fix this. I am trying to configure selenium in Ubuntu 20.04 Amazon EC2 instance.
Per the Chromedriver Download page,
If you are using Chrome version 91, please download ChromeDriver 91.0.4472.19

Jenkins run causes Selenium tests to fail with org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally?

I'm running Selenium tests for Chrome through Jenkins pipeline on CentOs machine. When ran, it gives following error -
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
[testng] (unknown error: DevToolsActivePort file doesn't exist)
[testng] (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
However if I run same tests with same command(which is used through Jenkins pipeline) from that machine locally, it succeeds.
For the same, I went through link1, link2, link3 and other answers. From those answers, only following helped -
chrome_options.add_argument('--headless')
But this run tests with chrome in headless mode which is not my intention.
In my case, having matching Chrome browser and chromedriver version did not help, also Chrome has executable permission for all.
Note: I've my CentOs machine display enabled
Could you please help to understand what is causing this failure? Also please help with what code and/or machine level changes I've to make for its success.
EDIT:
In case, this helps to get more info.
ls | grep 'chrome' under /usr/bin gave following result -
lrwxrwxrwx 1 root root 31 Jan 20 12:29 google-chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 32 Jan 20 12:29 google-chrome-stable -> /opt/google/chrome/google-chrome
Do you run chromedriver locally on a linux machine? What version of CentOS are you using? If you haven't already you need to install the correct chromedriver for linux. As far as I know if you want to run via Jenkins you have to run in headless mode. But I may be wrong. Below is another post that can help:
Steps to Install and run headless chrome browser on centos 6.5 using chrome driver
Below are my own settings for chrome options:
options.addArguments("--headless");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--allow-insecure-localhost");
options.addArguments("--window-size=1920,1080");
options.addArguments("start-maximized");
options.addArguments("enable-automation");
options.addArguments("--disable-infobars");
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--force-device-scale-factor=1");

Angular 5 karma unit test bug

When I do karma unit test in Angular5, I have some issues.
Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 SUCCESS (0 secs /
2.516 secs) Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to
load
'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'.
Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError:
Failed to execute 'send' on 'XMLHttpRequest': Failed to load
'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'.
at http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2281
Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 ERROR (0 secs /
2.516 secs) Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to
load
'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'.
Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 ERROR (2.546 secs
/ 2.516 secs)
I am not sure why this problem happened.
Please help me. Thanks.
I don't know if you managed this, but this errors could come from any input the component is waiting :)
If you have #Input() in your component, then you need to provide this input in your tests. Usually you can do it in beforeEach method :
beforeEach(() => {
fixture = TestBed.createComponent(YourComponent);
component = fixture.componentInstance;
component.yourInput = 'anyInput'
});