selenium: Replace ES5 one-var assignments with const/let per line
[lhc/web/wiklou.git] / tests / selenium / wdio-mediawiki / index.js
1 const fs = require( 'fs' );
2
3 module.exports = {
4 /**
5 * Based on <https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170>
6 *
7 * @since 1.0.0
8 * @param {string} title Description (will be sanitised and used as file name)
9 * @return {string} File path
10 */
11 saveScreenshot( title ) {
12 var filename, filePath;
13 // Create sane file name for current test title
14 filename = encodeURIComponent( title.replace( /\s+/g, '-' ) );
15 filePath = `${browser.config.screenshotPath}/${filename}.png`;
16 // Ensure directory exists, based on WebDriverIO#saveScreenshotSync()
17 try {
18 fs.statSync( browser.config.screenshotPath );
19 } catch ( err ) {
20 fs.mkdirSync( browser.config.screenshotPath );
21 }
22 // Create and save screenshot
23 browser.saveScreenshot( filePath );
24 return filePath;
25 }
26 };