mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-11-12 01:10:47 +00:00
Selenium: add selenium-daily NPM script
The script is needed to run the new Docker-based Jenkins job that runs daily and targets beta cluster. selenium-test script, NPM packages and wdio.conf.js files are dependencies. Change-Id: Ic0fb26cfdd07225260b6ef70ce81a49ee73af331 Job: RelatedArticles-npm-browser-run-selenium-daily-node-6-docker Bug: T188742
This commit is contained in:
parent
f6c23000f2
commit
5c8571317b
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -30,6 +30,7 @@ build/Release
|
|||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
||||
node_modules
|
||||
|
||||
/tests/selenium/log/
|
||||
|
||||
### Composer ###
|
||||
composer.phar
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"selenium-daily": "MEDIAWIKI_USER='Selenium user' MW_SERVER=https://en.wikipedia.beta.wmflabs.org npm run selenium-test",
|
||||
"selenium-test": "wdio tests/selenium/wdio.conf.js",
|
||||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -12,6 +14,9 @@
|
|||
"grunt-stylelint": "0.9.0",
|
||||
"stylelint": "8.2.0",
|
||||
"stylelint-config-wikimedia": "0.4.2",
|
||||
"wdio-mediawiki": "0.1.7"
|
||||
"wdio-mediawiki": "0.1.7",
|
||||
"wdio-mocha-framework": "0.6.1",
|
||||
"wdio-spec-reporter": "0.1.4",
|
||||
"webdriverio": "4.13.1"
|
||||
}
|
||||
}
|
||||
|
|
89
tests/selenium/wdio.conf.js
Normal file
89
tests/selenium/wdio.conf.js
Normal file
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* See also: http://webdriver.io/guide/testrunner/configurationfile.html
|
||||
*/
|
||||
const fs = require( 'fs' ),
|
||||
saveScreenshot = require( 'wdio-mediawiki' ).saveScreenshot;
|
||||
|
||||
exports.config = {
|
||||
// ======
|
||||
// Custom WDIO config specific to MediaWiki
|
||||
// ======
|
||||
// Use in a test as `browser.options.<key>`.
|
||||
// Defaults are for convenience with MediaWiki-Vagrant
|
||||
|
||||
// Wiki admin
|
||||
username: process.env.MEDIAWIKI_USER || 'Admin',
|
||||
password: process.env.MEDIAWIKI_PASSWORD || 'vagrant',
|
||||
|
||||
// Base for browser.url() and Page#openTitle()
|
||||
baseUrl: ( process.env.MW_SERVER || 'http://127.0.0.1:8080' ) + (
|
||||
process.env.MW_SCRIPT_PATH || '/w'
|
||||
),
|
||||
|
||||
// ==================
|
||||
// Test Files
|
||||
// ==================
|
||||
specs: [
|
||||
__dirname + '/specs/*.js'
|
||||
],
|
||||
|
||||
// ============
|
||||
// Capabilities
|
||||
// ============
|
||||
capabilities: [ {
|
||||
// https://sites.google.com/a/chromium.org/chromedriver/capabilities
|
||||
browserName: 'chrome',
|
||||
maxInstances: 1,
|
||||
chromeOptions: {
|
||||
// If DISPLAY is set, assume developer asked non-headless or CI with Xvfb.
|
||||
// Otherwise, use --headless (added in Chrome 59)
|
||||
// https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
|
||||
args: [
|
||||
...( process.env.DISPLAY ? [] : [ '--headless' ] ),
|
||||
// Chrome sandbox does not work in Docker
|
||||
...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
|
||||
]
|
||||
}
|
||||
} ],
|
||||
|
||||
// ===================
|
||||
// Test Configurations
|
||||
// ===================
|
||||
|
||||
// Level of verbosity: silent | verbose | command | data | result | error
|
||||
logLevel: 'error',
|
||||
|
||||
// Setting this enables automatic screenshots for when a browser command fails
|
||||
// It is also used by afterTest for capturig failed assertions.
|
||||
screenshotPath: process.env.LOG_DIR || __dirname + '/log',
|
||||
|
||||
// Default timeout for each waitFor* command.
|
||||
waitforTimeout: 10 * 1000,
|
||||
|
||||
// See also: http://webdriver.io/guide/testrunner/reporters.html
|
||||
reporters: [ 'spec' ],
|
||||
|
||||
// See also: http://mochajs.org
|
||||
mochaOpts: {
|
||||
ui: 'bdd',
|
||||
timeout: 60 * 1000
|
||||
},
|
||||
|
||||
// =====
|
||||
// Hooks
|
||||
// =====
|
||||
|
||||
/**
|
||||
* Save a screenshot when test fails.
|
||||
*
|
||||
* @param {Object} test Mocha Test object
|
||||
*/
|
||||
afterTest: function ( test ) {
|
||||
var filePath;
|
||||
if ( !test.passed ) {
|
||||
filePath = saveScreenshot( test.title );
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( '\n\tScreenshot: ' + filePath + '\n' );
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue