Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // to use debug option run `DEBUG=true followed by your .conf.js`
- /* eslint-disable global-require */
- // eslint-disable-next-line import/order
- const userJson = require('../decryptedcredentials.json');
- const path = require('path');
- global.allureDir = path.join('.', 'e2e/tests/reports/allure-results');
- const fs = require('fs');
- global.downloadDir = path.join(__dirname, 'downloads');
- function rmdir(dir) {
- const list = fs.readdirSync(dir);
- for (let i = 0; i < list.length; i++) {
- const filename = path.join(dir, list[i]);
- const stat = fs.statSync(filename);
- if (filename === '.' || filename === '..') {
- // pass these files
- } else if (stat.isDirectory()) {
- // rmdir recursively
- rmdir(filename);
- } else {
- // rm fiilename
- fs.unlinkSync(filename);
- }
- }
- fs.rmdirSync(dir);
- }
- exports.config = {
- // Global variables
- clientUsername: userJson.clientUser,
- clientPassword: userJson.clientPassword,
- invitationVendorUrl: userJson.invitationVendorUrl,
- betaCode: userJson.betaCode,
- vendorUsername: userJson.vendorUser,
- vendorPassword: userJson.vendorPassword,
- bankUsername: userJson.bankUser,
- bankPassword: userJson.bankPassword,
- clientApprovalUsername: userJson.clientApprovalUsername,
- clientApprovalPassword: userJson.clientApprovalPassword,
- vendorApprovalUsername: userJson.vendorApprovalUsername,
- vendorApprovalPassword: userJson.vendorApprovalPassword,
- payerApprovalUsername: userJson.payerApprovalUsername,
- payerApprovalPassword: userJson.payerApprovalPassword,
- vendorNoStripeUsername: userJson.vendorNoStripeUsername,
- vendorNoStripePassword: userJson.vendorNoStripePassword,
- hirerNoStripeUsername: userJson.hirerNoStripeUsername,
- hirerNoStripePassword: userJson.hirerNoStripePassword,
- vendorNoProjectsUsername: userJson.vendorNoProjectsUsername,
- vendorNoProjectsPassword: userJson.vendorNoProjectsPassword,
- vendorMultipleProjectsUsername: userJson.vendorMultipleProjectsUsername,
- vendorMultipleProjectsPassword: userJson.vendorMultipleProjectsPassword,
- clientMultipleProjectsUsername: userJson.clientMultipleProjectsUsername,
- clientMultipleProjectsPassword: userJson.clientMultipleProjectsPassword,
- clientNoProjectsUsername: userJson.clientNoProjectsUsername,
- clientNoProjectsPassword: userJson.clientNoProjectsPassword,
- clientOneProjectUsername: userJson.clientOneProjectUsername,
- clientOneProjectPassword: userJson.clientOneProjectPassword,
- //
- // ====================
- // Runner Configuration
- // ====================
- //
- // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
- // on a remote machine).
- runner: 'local',
- // ==================
- // Specify Test Files
- // ==================
- // Define which test specs should run. The pattern is relative to the directory
- // from which `WebdriverIO` was called. Notice that, if you are calling `wdio` from an
- // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
- // directory is where your package.json resides, so `wdio` will be called from there.
- //
- specs: ['./e2e/tests/specs/**/**/*.js'],
- // Patterns to exclude.
- exclude: [],
- //
- // ============
- // Capabilities
- // ============
- //
- maxInstances: 1,
- capabilities: [
- {
- maxInstances: 1,
- browserName: 'chrome',
- 'goog:chromeOptions': {
- args: ['window-size=1680,1050'],
- prefs: {
- 'download.default_directory': global.downloadDir
- }
- }
- }
- ],
- //
- // ===================
- // Test Configurations
- // ===================
- // Define all options that are relevant for the WebdriverIO instance here
- //
- // By default WebdriverIO commands are executed in a synchronous way using
- // the wdio-sync package. If you still want to run your tests in an async way
- // e.g. using promises you can set the sync option to false.
- sync: true,
- logLevel: 'silent', // Level of logging verbosity: silent | verbose | command | data | result | error
- logLevels: {
- webdriver: 'error',
- '@wdio/cli:Launcher': 'error',
- '@wdio/local-runner': 'error',
- '@wdio/utils:initialiseServices': 'error'
- },
- // Warns when a deprecated command is used
- deprecationWarnings: true,
- //
- // If you only want to run your tests until a specific amount of tests have failed use
- // bail (default is 0 - don't bail, run all tests).
- bail: 0,
- //
- // Set a base URL in order to shorten url command calls. If your url parameter starts
- // with "/", then the base url gets prepended.
- baseUrl: 'https://web-dev.poweredbyliquid.com/',
- waitforTimeout: 120000, // Default timeout for all waitFor* commands.
- connectionRetryTimeout: 60000, // Default timeout in milliseconds for request if Selenium Grid doesn't send response
- connectionRetryCount: 1, // Default request retries count
- services: ['selenium-standalone', 'intercept', 'shared-store'],
- framework: 'mocha',
- mochaOpts: {
- ui: 'bdd',
- timeout: 120000,
- compilers: ['js:@babel/register']
- },
- reporters: [
- 'spec',
- [
- 'allure',
- {
- outputDir: './e2e/tests/reports/allure-results/',
- disableWebdriverStepsReporting: false,
- disableWebdriverScreenshotsReporting: false,
- useCucumberStepReporter: false
- }
- ]
- ],
- //
- // =====
- // Hooks
- // =====
- onPrepare() {
- console.log('**** Starting test... ****');
- const screenshotsFolder = `./e2e/tests/reports/screenshots`;
- // make sure download directory exists
- if (!fs.existsSync(global.downloadDir)) {
- // if it doesn't exist, create it
- fs.mkdirSync(global.downloadDir, { recursive: true });
- }
- if (fs.existsSync(global.allureDir)) {
- rmdir(global.allureDir);
- }
- if (!fs.existsSync(screenshotsFolder)) {
- // if it doesn't exist, create it
- fs.mkdirSync(screenshotsFolder, { recursive: true });
- } else {
- rmdir(screenshotsFolder);
- fs.mkdirSync(screenshotsFolder, { recursive: true });
- }
- },
- /**
- * Gets executed just before initialising the webdriver session and test framework. It allows you
- * to manipulate configurations depending on the capability or spec.
- * @param {Object} config wdio configuration object
- * @param {Array.<Object>} capabilities list of capabilities details
- * @param {Array.<String>} specs List of spec file paths that are to be run
- */
- beforeSession() {
- require('@babel/register');
- },
- /**
- // Gets executed before test execution begins. At this point you can access all global
- // variables, such as `browser`. It is the perfect place to define custom commands.
- * @param {Array.<Object>} capabilities list of capabilities details
- * @param {Array.<String>} specs List of spec file paths that are to be run
- */
- before() {
- /**
- * Setup the Chai assertion framework
- */
- const chai = require('chai');
- global.expect = chai.expect;
- global.assert = chai.assert;
- global.should = chai.should();
- },
- afterTest(test) {
- if (test.error !== undefined) {
- browser.takeScreenshot();
- }
- },
- //
- // Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
- // afterEach in Mocha)
- // afterHook: function (currentTest) {
- // },
- /**
- * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
- * @param {Object} test test details
- */
- // Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
- // beforeTest: function (test) {
- // },
- /**
- * Runs before a WebdriverIO command gets executed.
- * @param {String} commandName hook command name
- * @param {Array} args arguments that command would receive
- */
- // beforeCommand: function (commandName, args) {
- // },
- /**
- * Runs after a WebdriverIO command gets executed
- * @param {String} commandName hook command name
- * @param {Array} args arguments that command would receive
- * @param {Number} result 0 - command success, 1 - command error
- * @param {Object} error error object if any
- */
- // afterCommand: function (commandName, args, result, error) {
- // },
- /**
- * Hook that gets executed after the suite has ended
- * @param {Object} suite suite details
- */
- // afterSuite: function (suite) {
- // },
- /**
- * Gets executed after all tests are done. You still have access to all global variables from
- * the test.
- * @param {Number} result 0 - test pass, 1 - test fail
- * @param {Array.<Object>} capabilities list of capabilities details
- * @param {Array.<String>} specs List of spec file paths that ran
- */
- // after: function (result, capabilities, specs) {
- // },
- /**
- * Gets executed right after terminating the webdriver session.
- * @param {Object} config wdio configuration object
- * @param {Array.<Object>} capabilities list of capabilities details
- * @param {Array.<String>} specs List of spec file paths that ran
- */
- // afterSession: function (config, capabilities, specs) {
- // },
- /**
- * Gets executed after all workers got shut down and the process is about to exit. It is not
- * possible to defer the end of the process using a promise.
- * @param {Object} exitCode 0 - success, 1 - fail
- */
- onComplete() {
- console.log('**** Test Finished ****');
- rmdir(global.downloadDir);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement