I'm having a not very meaningful error on my gitlab CI server when running e2e tests.
[22:40:18] I/launcher - Running 1 instances of WebDriver
[22:40:18] I/local - Starting selenium standalone server...
[22:40:18] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (/selenium-webdriver/remote/index.js:252:52)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[22:40:18] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! guide-scanner-web#0.0.0 e2e-ci: `ng e2e --conf protractor-ci.conf.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the guide-scanner-web#0.0.0 e2e-ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-11-28T22_40_19_015Z-debug.log
ERROR: Job failed: exit code 1
Here is the protractor.conf.js
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ["--headless", '--no-sandbox', "--disable-gpu", "--window-size=800x600"]
}
},
chromeDriver: '/selenium-grid/chromedriver_2.33',
seleniumServerJar: "/selenium-grid/selenium-server-standalone-3.7.1.jar",
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
the job desciption in my gitlab-ci.yml
before_script:
- npm install
e2e:
stage: testing
script:
- apt-get update -y
- apt-get install default-jre -y
- npm install -g webdriver-manager
- webdriver-manager update --out_dir /selenium-grid
- npm run e2e
And here is my package.json:
"#angular/language-service": "^5.0.0"
"#types/jasmine": "~2.5.53"
"#types/jasminewd2": "~2.0.2"
"#types/node": "~6.0.60"
"codelyzer": "~3.2.2"
"jasmine-core": "~2.6.2"
"jasmine-spec-reporter": "~4.1.0"
"karma": "~1.7.0"
"karma-chrome-launcher": "~2.1.1"
"karma-cli": "~1.0.1"
"karma-coverage-istanbul-reporter": "^1.2.1"
"karma-jasmine": "~1.1.0"
"karma-jasmine-html-reporter": "^0.2.2"
"protractor": "~5.1.2"
"ts-node": "~3.2.0"
"tslint": "~5.7.0"
"typescript": "~2.4.2"
I've been struggling on setting up the CI for a little while now so any suggestions will be very much appreciated ^^'
Just use image with headless chrome preinstalled. Here is my script for Gitlab pipelines:
cache:
paths:
- node_modules/
before_script:
- npm cache clean --force
- npm install && npm rebuild
stages:
- test
- build
build:
image: node:alpine
stage: build
script:
- ./node_modules/#angular/cli/bin/ng build --prod
test:
image: gnomeontherun/docker-node-chrome-headless:latest
stage: test
script:
- ./node_modules/#angular/cli/bin/ng test --watch=false --single-run=true
Related
I'm experiencing CI using GitHub action.
I had a problem with installing dependencies on every CI and found that I could solve this with actions/cache.
Here is my part of action.yaml
- name: Cache npm dependency
uses: actions/cache#v3
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- if: steps.npm-cache.outputs.cache-hit != true
name: Install Dependency
run: |
echo 'npm cache missed'
npm ci
And restore the cache in Cache npm dependency step.
Cache restored successfully
Cache restored from key: Linux-npm-...
But it always reinstalls dependencies in 'Install Dependency' step.
Run echo 'npm cache missed'
echo 'npm cache missed'
npm ci
shell: /usr/bin/bash -e {0}
npm cache missed
> nodemon#2.0.16 ...
> node bin/postinstall || exit 0
added 661 packages in 19.862s
As a result, caching becomes meaningless.
What am i missing or doing wrong?
I solved it by modifying it like this: != true -> != 'true'
Our Azure build pipeline started failing today. This was working fine with the same code a few days back. I'm struggling to find a reason. The build works fine in my local machine but doesn’t work on DevOps.
Below are some lines from the error log. Can anyone guide me to find the issue please?
Start of the error in the logs:
2021-12-04T09:08:08.1234486Z 6728 timing metavuln:packument:sass-loader Completed in 28ms
2021-12-04T09:08:08.1234976Z 6729 timing metavuln:load:security-advisory:sass-loader:sKa4m2v9CoUt2NE/HFdn2iHPGTVRUKpbo4oLNnOVBTLyHGQ/KmGqhFuwUlvkR/owQNQEXwZFOGQt5TNCCkoHWw== Completed in 5ms
2021-12-04T09:08:08.1235699Z 6730 timing metavuln:cache:put:security-advisory:sass-loader:0+Q0+uaac9NG7L1nbkGVbvFbaBvbLzENFqRpXWUE7U0t2jjSSjVZ79o6UtQRkcjQ/gcgS0kd8p2vAnNjva/3Eg== Completed in 15ms
2021-12-04T09:08:08.1236341Z 6731 timing metavuln:calculate:security-advisory:sass-loader:sKa4m2v9CoUt2NE/HFdn2iHPGTVRUKpbo4oLNnOVBTLyHGQ/KmGqhFuwUlvkR/owQNQEXwZFOGQt5TNCCkoHWw== Completed in 48ms
2021-12-04T09:08:08.1237034Z 6732 timing metavuln:cache:get:security-advisory:imagemin-jpegtran:s0MaKyyWWIoVMQAlu89TduB0lW+w9ANmAjDodgTT4fcy4ki3FsHrWalCv/COtdz4o3adGXtGYSamW2jub7ta+Q== Completed in 1ms
2021-12-04T09:08:08.1237558Z 6733 info run node-sass#4.14.1 postinstall { code: 1, signal: null }
2021-12-04T09:08:08.1238006Z 6734 http fetch GET 200 https://registry.npmjs.org/imagemin-jpegtran 5491ms (cache miss)
2021-12-04T09:08:08.1238399Z 6735 timing metavuln:packument:imagemin-jpegtran Completed in 5491ms
2021-12-04T09:08:08.1238952Z 6736 timing metavuln:load:security-advisory:imagemin-jpegtran:u6oOqPrIyXrFjQnhqewixjKDTSD2uoKmmWFnU4zRuXrk8rdHkm8zODnNe7xy3697n8Yy/cBLgdQBE6mFa/kxsg== Completed in 1ms
2021-12-04T09:08:08.1239443Z 6737 timing reify:rollback:createSparse Completed in 5296ms
2021-12-04T09:08:08.1239823Z 6738 timing reify:rollback:retireShallow Completed in 0ms
2021-12-04T09:08:08.1240144Z 6739 timing command:install Completed in 77131ms
2021-12-04T09:08:08.1240444Z 6740 verbose stack Error: command failed
2021-12-04T09:08:08.1240974Z 6740 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
2021-12-04T09:08:08.1241517Z 6740 verbose stack at ChildProcess.emit (node:events:390:28)
2021-12-04T09:08:08.1241956Z 6740 verbose stack at maybeClose (node:internal/child_process:1064:16)
2021-12-04T09:08:08.1242405Z 6740 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
2021-12-04T09:08:08.1242817Z 6741 verbose pkgid node-sass#4.14.1
2021-12-04T09:08:08.1243073Z 6742 verbose cwd D:\a\1\s
2021-12-04T09:08:08.1243323Z 6743 verbose Windows_NT 10.0.17763
2021-12-04T09:08:08.1243767Z 6744 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
2021-12-04T09:08:08.1244152Z 6745 verbose node v16.13.0
2021-12-04T09:08:08.1244424Z 6746 verbose npm v8.1.0
2021-12-04T09:08:08.1244643Z 6747 error code 1
2021-12-04T09:08:08.1244930Z 6748 error path D:\a\1\s\node_modules\gulp-sass\node_modules\node-sass
2021-12-04T09:08:08.1245270Z 6749 error command failed
2021-12-04T09:08:08.1245577Z 6750 error command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
2021-12-04T09:08:08.1246161Z 6751 error Building: C:\Program Files\nodejs\node.exe D:\a\1\s\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
2021-12-04T09:08:08.1246648Z 6752 error gyp info it worked if it ends with ok
Last few lines of the log:
2021-12-04T09:08:08.1681219Z 6752 error gyp verb node dev dir C:\Users\VssAdministrator\.node-gyp\16.13.0
2021-12-04T09:08:08.1681621Z 6752 error gyp verb found first Solution file build/binding.sln
2021-12-04T09:08:08.1682050Z 6752 error gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
2021-12-04T09:08:08.1682559Z 6752 error gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
2021-12-04T09:08:08.1682993Z 6752 error gyp info spawn args [
2021-12-04T09:08:08.1683269Z 6752 error gyp info spawn args 'build/binding.sln',
2021-12-04T09:08:08.1683573Z 6752 error gyp info spawn args '/nologo',
2021-12-04T09:08:08.1683893Z 6752 error gyp info spawn args '/p:Configuration=Release;Platform=x64'
2021-12-04T09:08:08.1684205Z 6752 error gyp info spawn args ]
2021-12-04T09:08:08.1684463Z 6752 error gyp ERR! UNCAUGHT EXCEPTION
2021-12-04T09:08:08.1684876Z 6752 error gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe ENOENT
2021-12-04T09:08:08.1685424Z 6752 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
2021-12-04T09:08:08.1685894Z 6752 error gyp ERR! stack at onErrorNT (node:internal/child_process:477:16)
2021-12-04T09:08:08.1686366Z 6752 error gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21)
2021-12-04T09:08:08.1686766Z 6752 error gyp ERR! System Windows_NT 10.0.17763
2021-12-04T09:08:08.1687321Z 6752 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\a\\1\\s\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2021-12-04T09:08:08.1687915Z 6752 error gyp ERR! cwd D:\a\1\s\node_modules\gulp-sass\node_modules\node-sass
2021-12-04T09:08:08.1688248Z 6752 error gyp ERR! node -v v16.13.0
2021-12-04T09:08:08.1688513Z 6752 error gyp ERR! node-gyp -v v3.8.0
2021-12-04T09:08:08.1688788Z 6752 error gyp ERR! This is a bug in `node-gyp`.
2021-12-04T09:08:08.1689164Z 6752 error gyp ERR! Try to update node-gyp and file an Issue if it does not help:
2021-12-04T09:08:08.1689568Z 6752 error gyp ERR! <https://github.com/nodejs/node-gyp/issues>
2021-12-04T09:08:08.1689916Z 6752 error Build failed with error code: 7
2021-12-04T09:08:08.1690179Z 6753 verbose exit 1
2021-12-04T09:08:08.1690283Z
2021-12-04T09:08:08.1720104Z ##[error]Error: Npm failed with return code: 1
2021-12-04T09:08:08.1747833Z ##[section]Finishing: Npm
Below is the yaml file
name: 1.0.$(BuildID)-$(SourceBranchName)
trigger:
- release
variables:
versionNumber: '1.0.$(BuildID)'
mvcSolution: 'SVHA.MVC.Web.sln'
jobs:
- job: "BuildStaging"
variables:
buildConfiguration: 'Staging'
buildPlatform: 'Any CPU'
pool:
vmImage: 'windows-latest'
steps:
- task: Npm#1
inputs:
command: 'install'
workingDir: './'
- task: CmdLine#2
inputs:
script: 'npm run apps-build'
workingDirectory: './'
- task: Gulp#1
inputs:
gulpFile: 'gulpfile.js'
targets: 'build'
arguments: '--production'
enableCodeCoverage: false
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(mvcSolution)'
- task: VSBuild#1
inputs:
solution: '$(mvcSolution)'
msbuildArgs: '/t:Rebuild /p:Configuration=Staging;DeployOnBuild=true;DeployTarget=Package;AutoParameterizationWebConfigConnectionStrings=False;_PackageTempDir="$(Build.BinariesDirectory)\mvc"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
inputs:
SourceFolder: 'src\SVHA.Web\Config\staging'
Contents: 'connectionStrings.config'
TargetFolder: '$(Build.BinariesDirectory)\mvc\Config'
OverWrite: true
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)\mvc'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\mvc.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'staging'
publishLocation: 'Container'
Remove node-sass and install sass instead.
I have added the below steps to run unit test in Azure pipelines for React UI.
Added a file , File name:jestTrxProcessor.js. The content:
var builder = require("jest-trx-results-processor/dist/testResultsProcessor");
var builder = require("jest-trx-results-processor");
var processor = builder({
outputFile: "jestTestresults.trx",
});
module.exports = processor;
In package.json I entered the below code:
"scripts": {
....
"test": "jest"
},
devdependencies{
...
"jest": "^23.4.1",
"jest-trx-results-processor": "0.0.7",
"jsdom": "^11.12.0"
},
"jest": {
"testResultsProcessor": "./__tests__/jestTrxProcessor.js",
"reporters": [
"default",
[
"jest-trx-results-processor",
{
"outputFile": "./__tests__/jestTestresults.trx",
}
]]},
3.In the yaml file I added the below script:
- script: |
npm install
npm install jest-trx-results-processor --save-dev
yarn add --dev jest-trx-results-processor
npm run build
# npm run test
displayName: 'npm install and build'
- task: PublishTestResults#2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: './__tests__/jestTestresults.trx'
testRunTitle: 'FrontEnd Test'
I am getting the below error:
Failed to parse result files when VSTest is run Azure pipelines
According to the error message:
Publish Test Results Failed to parse result files:
System.Xml.XmlException: Data at the root level is invalid. Line 1,
position 1
It means that you have attempted to parse something that is not an XML document or there is a issue with the generated trx file.
To troubleshooting this issue, please try to update the devdependencies jest jest-trx-results-processor:
"devDependencies": {
"jest": "^26.6.3",
"jest-trx-results-processor": "~2.0.0"
},
And try to select JUnit in TestResultsFormat:
Besides, the Jest testResultsProcessor property is deprecated, please try to use the jest-junit package for test reports:
Please check this thread for some more details.
I am trying to integrate protractor e2e tests on my circleCi with the following setup:
config.yml
- run:
name: NPM test
command: |
cd frontend
npm install
apk update
apk add chromium
export CHROME_BIN=$(which chromium-browser)
npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI --code-coverage || exit 0
- run:
name: Protractor e2e tests
command: |
cd frontend
npm run e2e -- --protractor-config=./e2e/protractor-ci.conf.js
protractor config:
const config = require('./protractor.conf').config;
config.capabilities = {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--no-sandbox']
}
};
exports.config = config;
Unit test run with success, although e2e tests are not running:
[10:12:58] I/file_manager - creating folder /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium
[10:12:58] I/config_source - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
ℹ 「wdm」: Compiled successfully.
[10:12:58] I/downloader - curl -o/root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69.zip https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_linux64.zip
[10:12:59] I/update - chromedriver: unzipping chromedriver_81.0.4044.69.zip
[10:12:59] I/update - chromedriver: setting permissions to 0755 for /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69
[10:12:59] I/launcher - Running 1 instances of WebDriver
[10:12:59] I/direct - Using ChromeDriver directly...
[10:12:59] E/launcher - spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
[10:12:59] E/launcher - Error: spawn /root/project/frontend/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.69 ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
at onErrorNT (internal/child_process.js:421:16)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
[10:12:59] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
Setup:
Angular CLI: 7.3.9
Node: 10.19.0
Protractor: 5.4.3
Already tried:
- Update webdriver before the tests started.
- Already check thatc hromedriver_81.0.4044.69 file is on the folder of the error
I've an error on circleci that i'm not able to understand. It says that Chrome version must be between 70 and 73 when using selenium chrome webdriver.
[21:58:05] I/downloader - curl -o/home/circleci/project/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.45.zip https://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip
[21:58:05] I/update - chromedriver: unzipping chromedriver_2.45.zip
[21:58:05] I/update - chromedriver: setting permissions to 0755 for /home/circleci/project/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.45
[21:58:05] I/launcher - Running 1 instances of WebDriver
[21:58:05] I/direct - Using ChromeDriver directly...
[21:58:06] E/launcher - session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.4.0-141-generic x86_64)
[21:58:06] E/launcher - SessionNotCreatedError: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.4.0-141-generic x86_64)
at Object.checkLegacyResponse (/home/circleci/project/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/home/circleci/project/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/home/circleci/project/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/circleci/project/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/home/circleci/project/node_modules/selenium-webdriver/chrome.js:761:15)
at Direct.getNewDriver (/home/circleci/project/node_modules/protractor/built/driverProviders/direct.js:77:33)
at Runner.createBrowser (/home/circleci/project/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/home/circleci/project/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/home/circleci/project/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/circleci/project/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/circleci/project/node_modules/q/q.js:796:13)
at /home/circleci/project/node_modules/q/q.js:556:49
at runSingle (/home/circleci/project/node_modules/q/q.js:137:13)
[21:58:06] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
my circleci config file
version: 2
jobs:
build:
docker:
- image: circleci/node:8.11-browsers
working_directory: ~/project
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
- run: npm run e2e
Any idea of what is happening ?
This isn't a problem specific to Circle CI. I was receiving it on my regular IDE setup. The issue is that your chromedriver no longer matches the browser version.
Steps to fix (I'm using Mac OSX):
- Upgrade your chrome browser to latest: currently 74
- Upgrade your chromedriver to latest: you can manually download it from their site, or if installed via brew cask just run brew cask upgrade
This worked for me. In circle.yml
- run:
name: Install Chrome
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
Other solutions like using -browsers docker images does not work now
One idea would be to download and install the latest Chrome in the .circleci/config.yml file (similar to #andriy-baran's comment). However, that might use up your build time unless there's a way to cache the Chrome engine directory together with its dependencies.
Check your Chrome version Help -> About Google Chrome.
Download the matching Chromedriver from http://chromedriver.chromium.org/downloads
Should solve the issue.