Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shridharkalagi/03d0c0f55bc154912886ce23ac8d5c55 to your computer and use it in GitHub Desktop.
Save shridharkalagi/03d0c0f55bc154912886ce23ac8d5c55 to your computer and use it in GitHub Desktop.
exports.config = {
baseUrl: 'https://www-test.com',
// ======================
// Grid Node Capabilities
// ======================
//
// capabilities: {
// maxInstances: 1,
// browserName: 'chrome'
// },
// ===========================
// Browser stack Configuration
// ===========================
host: 'hub-use.browserstack.com',
port: 80,
user: '',
key: '',
screenshotOnReject: false,
reporters: [
'dot', 'spec', JsonReporter, 'mochawesome', EchoReporter
],
reporterOptions: {
outputDir: './Results',
embedScreenshots: true,
screenshotExtension: '.png'
},
logLevel: 'silent',
coloredLogs: true,
// ======================
// Timeout Configurations
// ======================
// Default timeout for all waitForXXX commands.
timeout: 80000,
waitforTimeout: 5000,
connectionRetryTimeout: 90000,
connectionRetryCount: 1,
// =============================
// Test Framework Configurations
// =============================
framework: 'mocha',
// specs: [
// './test/**.js'
// ],
suites: {
smoke: [
'./test/Smoke.spec.js'
]
},
// Options to be passed to Mocha.
mochaOpts: {
ui: 'tdd',
compilers: ['js:@babel/register'],
applicationCategory: ' Fresh',
timeout: 10 * 60 * 1000
},
// =====
// Hooks
// =====
// Set spec name as session name in browserstack dashboard
beforeSession: function (config, capabilities, specs) {
capabilities.name = specs && specs[0].split('/').pop() || undefined;
},
// Gets executed once before all workers get launched.
onPrepare: function () {
var fs = require('fs');
// Create Report Directory
if (!fs.existsSync(this.reporterOptions.outputDir)) {
fs.mkdirSync(this.reporterOptions.outputDir);
}
// Create Screenshot Directory
if (!fs.existsSync(this.reporterOptions.outputDir + '/screenshots/')) {
fs.mkdirSync(this.reporterOptions.outputDir + '/screenshots/');
}
console.log('Connecting to Browserstack');
const args = {
'user': '',
'key': '',
// 'proxyHost': '',
// 'proxyPort': '3128',
// 'proxyUser': process.env.PROXY_USER,
// 'proxyPass': process.env.PROXY_PASS,
'localIdentifier': process.env.BUILD_NO,
'force': 'true'
}
return new Promise(function (resolve, reject) {
exports.bs_local = new browserstack.Local();
exports.bs_local.start(args, function (error) {
if (error) {
return reject(error)
}
console.log('Connected. Now testing...');
resolve()
})
})
},
// Gets executed before Tests execution begins. At this point you can access to all global
// variables like `browser`. It is the perfect place to define custom commands.
before: function () {
// verify = require('kroger-verify');
// assert = require('chai').assert;
// browserDetails();
},
// Runs after a WebdriverIO command gets executed
afterTest: function (test) {
if (!(test.err === undefined)) {
// capture screenprint for assertion errors.
if (test.passed === false && test.err.message.indexOf('Verify') === -1) {
var screenshotName = this.reporterOptions.outputDir + '/screenshots/' + test.title + '_' + browser.desiredCapabilities.browserName + '.png';
browser.saveScreenshot(screenshotName);
}
}
},
onComplete: function () {
exports.bs_local.stop(function () {})
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment