J'ai généré un projet VueJS en utilisant vue-cli, y compris des tests de bout en bout avec Nightswatch.js.
J'utilise le fichier .gitlab-ci.yml suivant
services:
- selenium/standalone-chrome
stages:
- test
- pages
test:
image: node:6.11
stage: test
before_script:
- node -v
- npm -v
script:
- npm install
- npm test
pages:
image: node:6.11
stage: pages
before_script:
- node -v
- npm -v
script:
- npm install
- npm run build
- cp -R ./dist ./public
- cd ./public
- ls
artifacts:
paths:
- public
only:
- master
C'est le nightswatch.conf.js
fichier
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
Dans Gitlab-CI, le travail passe mais en regardant le journal, seuls les tests unitaires passent, pas les tests de bout en bout.
> node test/e2e/runner.js
Starting selenium server...
An error occurred while trying to start Selenium. Check if JAVA is installed on your machine.
{ Error: spawn java ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:32)
at onErrorNT (internal/child_process.js:376:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn java',
path: 'java',
spawnargs:
[ '-Dwebdriver.chrome.driver=/builds/Overdrivr/frontend/node_modules/chromedriver/lib/chromedriver/chromedriver',
'-jar',
'/builds/Overdrivr/frontend/node_modules/selenium-server/lib/runner/selenium-server-standalone-3.8.1.jar',
'-port',
4444 ] }
INFO Selenium process finished.
Job succeeded
Comment puis-je configurer correctement gitlab-ci ou nightswatch pour exécuter des tests e2e dans Gitlab-CI ?