import {ReportGenerator, HtmlReporter, ReportAggregator} from 'wdio-html-nice-reporter'; let reportAggregator: ReportAggregator; export const config = { runner: 'local', // protocol: 'http', // hostname: 'selenium-grid-selenium-hub-grid.apps.cluster-mgcjz.dynamic.redhatworkshops.io', // port: 80, // path: '/', specs: [ './app/**/*.test.js' ], maxInstances: 10, capabilities: [ { browserName: 'firefox' }, // { // browserName: 'MicrosoftEdge' // }, // { // browserName: 'chrome' // or "firefox", "microsoftedge", "safari" // }, ], logLevel: 'debug', // 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 `/`, the base url gets prepended, not including the path portion of your baseUrl. // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url // gets prepended directly. // baseUrl: 'http://localhost:8080', // // Default timeout for all waitFor* commands. waitforTimeout: 10000, // // Default timeout in milliseconds for request // if browser driver or grid doesn't send response connectionRetryTimeout: 120000, // // Default request retries count connectionRetryCount: 3, // // Test runner services // Services take over a specific job you don't want to take care of. They enhance // your test setup with almost no effort. Unlike plugins, they don't add new // commands. Instead, they hook themselves up into the test process. // services: [], // // Framework you want to run your specs with. // The following are supported: Mocha, Jasmine, and Cucumber // see also: https://webdriver.io/docs/frameworks // // Make sure you have the wdio adapter package for the specific framework installed // before running any tests. framework: 'mocha', // // The number of times to retry the entire specfile when it fails as a whole // specFileRetries: 1, // // Delay in seconds between the spec file retry attempts // specFileRetriesDelay: 0, // // Whether or not retried spec files should be retried immediately or deferred to the end of the queue // specFileRetriesDeferred: false, // // Test reporter for stdout. // The only one supported by default is 'dot' // see also: https://webdriver.io/docs/dot-reporter reporters: ['spec', ["html-nice", { debug: true, outputDir: './reports/html-reports/', filename: 'report.html', reportTitle: 'Web Test Report', showInBrowser: false, useOnAfterCommandForScreenshot: false, linkScreenshots: true }] ], // Options to be passed to Mocha. // See the full list at http://mochajs.org/ mochaOpts: { ui: 'bdd', timeout: 60000 }, /** * Gets executed before test execution begins. At this point you can access to all global * variables like `browser`. It is the perfect place to define custom commands. * @param {Array.} capabilities list of capabilities details * @param {Array.} specs List of spec file paths that are to be run */ before: function (capabilities, specs) { //@ts-ignore }, onPrepare: function (config, capabilities) { reportAggregator = new ReportAggregator( { outputDir: './reports/html-reports/', filename: process.env.TEST_BROWSER + '-master-report.html', reportTitle: 'Micro-Magic Web Test Report', browserName: process.env.TEST_BROWSER ? process.env.TEST_BROWSER : 'unspecified', showInBrowser: true }); reportAggregator.clean(); }, afterTest: function (test: any, context: any, result: any) { // if test passed, ignore, else take and save screenshot. if (result.passed) { return; } //@ts-ignore driver.logScreenshot(String.format("Test Ended in {0}", result.error.stack)); }, onComplete: function (exitCode, config, capabilities, results) { (async () => { await reportAggregator.createReport(); })(); } }