Reputation: 1709
This is my test project Github Repo for React test
Got it working!!
It builds successfully on my pc in chrome and firefox
But, when I try to build it in travis CI, it doesn't execute. By the way, I am trying the test to be run headless mode as in travis-ci docs headless chrome
What am I missing?
This is my .travis.yml
file content:
language: node_js
node_js:
- '8.9'
dist: trusty
addons:
chrome: stable
before_install:
- # start your web application and listen on `localhost`
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
Travis CI Error Log:
[email protected] test /home/travis/build/sabbiu/react-test
> wdio wdio.conf.js
[13:34:05] COMMAND POST "/wd/hub/session"
[13:34:05] DATA {"desiredCapabilities": {"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"maxInstances":5,"browserName":"chrome","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.12.0","name":"webdriverio"}}}
ERROR: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.36.540471
(9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.14.12-041412-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.35 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'travis-job-sabbiu-react-test-360271390', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.12-041412-generic', java.version: '1.8.0_151'
Driver info: driver.version: unknown
chrome
at new RuntimeError (/home/travis/build/sabbiu/react-test/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
at Request._callback (/home/travis/build/sabbiu/react-test/node_modules/webdriverio/build/lib/utils/RequestHandler.js:316:39)
at Request.self.callback (/home/travis/build/sabbiu/react-test/node_modules/webdriverio/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/home/travis/build/sabbiu/react-test/node_modules/webdriverio/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/travis/build/sabbiu/react-test/node_modules/webdriverio/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
npm ERR! Test failed. See above for more details.
The command "npm test" exited with 1.
Done. Your build exited with 1.
Package.json file
{
"name": "react-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "wdio wdio.conf.js"
},
"author": "",
"license": "MIT",
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"mocha": "^5.0.5",
"selenium-standalone": "^6.13.0",
"wdio-mocha-framework": "^0.5.13",
"wdio-selenium-standalone-service": "0.0.10",
"wdio-spec-reporter": "^0.1.4",
"webdriverio": "^4.12.0"
}
}
UPDATES
I got it working with xvfb. But, I am still looking for it to work with chrome --headless.
.travis.yml
file with xvfb
language: node_js
node_js:
- '8.9'
sudo: required
cache:
directories:
- node_modules
addons:
chrome: stable
before_install:
# starting a GUI to run tests, per https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "npm config set spin false"
before_script:
- "npm install"
script: "npm test"
Upvotes: 0
Views: 726
Reputation: 1709
Turns out I was missing chromeOptions
in wdio.config.js
file
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
chromeOptions: {
args: ['headless', 'disable-gpu']
}
}],
After puting that it worked like a charm.
Upvotes: 3