Open himildesai opened 3 years ago
@himildesai could I see your reporter section of wdio.conf.js? that is usually where the error is.
@Namrata-m13 Thanks for replying following is my browserstack specific config
exports.config = {
...config,
...{
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
services: ['browserstack'],
reporters: ['browserstack'],
browserstackLocal: false,
baseUrl: options.baseUrl || 'google.com',
host: 'hub.browserstack.com',
capabilities: [
{
os_version: '10.0',
device: 'Samsung Galaxy S20',
real_mobile: 'true',
'browserstack.networkLogs': 'true',
'browserstack.local': 'false',
browserName: 'Android'
}
]
}
};
And following is my wdio.conf.js
const options = require('minimist')(process.argv.slice(2));
const video = require('wdio-video-reporter');
const headless = options.headless;
exports.config = {
//
// ====================
// 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 `wdio` 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: ['./test/functional/**/*.spec.ts'],
path: '/wd/hub',
// Define specific suites
suites: {
// checkout: ['test/functional/tests/email.spec.js']
},
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
// First, you can define how many instances should be started at the same time. Let's
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
// files and you set maxInstances to 10, all spec files will get tested at the same time
// and 30 processes will get spawned. The property handles how many capabilities
// from the same test should run tests.
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
capabilities: (options.browser || defaultBrowsers())
.split(',')
.map((browserName) => defaultBrowserCapabilities(browserName)),
//
// ===================
// 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,
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
//
// Set specific log levels per logger
// loggers:
// - webdriver, webdriverio
// - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
// - @wdio/mocha-framework, @wdio/jasmine-framework
// - @wdio/local-runner, @wdio/lambda-runner
// - @wdio/sumologic-reporter
// - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils
// Level of logging verbosity: trace | debug | info | warn | error | silent
// logLevels: {
// webdriver: 'info',
// '@wdio/applitools-service': 'info'
// },
//
// 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: 'google.com',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 30000,
waitforInterval: 2000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 90000,
//
// 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.
// selenium-standalone runs the test by default on standalone selenium.
// This can be overridden by passing hostname and port of the selenium grid
services: [],
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: https://webdriver.io/docs/frameworks.html
//
// 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,
//
// Test reporter for stdout.
// The only one supported by default is 'dot'
// see also: https://webdriver.io/docs/dot-reporter.html
reporters: [
'spec',
[
video,
{
saveAllVideos: false, // If true, also saves videos for successful test cases
videoSlowdownMultiplier: 10, // Higher to get slower videos, lower for faster videos [Value 1-100]
videoRenderTimeout: 5 // Max seconds to wait for a video to finish rendering
}
],
[
'junit',
{
outputDir: './out/functional/junit',
outputFileFormat: function (opts) {
return `results-${opts.cid}.${opts.capabilities}.xml`;
}
}
],
[
'allure',
{
outputDir: './out/functional/allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: true
}
]
],
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
ui: 'bdd',
timeout: 100000,
retries: `${process.env.RETRIES}`,
compilers: ['tsconfig-paths/register']
},
// For TypeScript
autoCompileOpts: {
tsNodeOpts: {
transpileOnly: true,
project: './test/functional/tsconfig.json'
}
},
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
/**
* Gets executed once before all workers get launched.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
*/
// onPrepare: function (config, capabilities) {
// },
/**
* 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: function (config, capabilities, specs) {
// },
/**
* 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.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that are to be run
*/
before: function () {
browser.addCommand(
'waitUntilUrlContains',
function (expectedUrlFragment, options) {
// `this` refers to the `browser` scope
const timeoutMsg =
(options && options.timeoutMsg) ||
`url did not contain ${expectedUrlFragment} before timeout`;
const resolvedOptions = { ...options, timeoutMsg };
this.waitUntil(
() => this.getUrl().includes(expectedUrlFragment),
resolvedOptions
);
}
);
},
/**
* 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) {
// },
/**
* Hook that gets executed before the suite starts
* @param {Object} suite suite details
*/
// beforeSuite: function (suite) {
// },
/**
* Function to be executed before a test (in Mocha/Jasmine) starts.
*/
beforeTest: function (test, context) {
browser.maximizeWindow();
},
/**
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
* beforeEach in Mocha)
*/
// beforeHook: function (test, context) {
// },
/**
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
* afterEach in Mocha)
*/
// afterHook: function (test, context, { error, result, duration, passed, retries }) {
// },
/**
* Function to be executed after a test (in Mocha/Jasmine).
*/
afterTest: function (test) {
if (!test.passed) {
browser.takeScreenshot();
}
browser.reloadSession();
}
};
/**
* Default browser
*/
function defaultBrowsers() {
switch (options.platform) {
case 'mac':
return 'chrome,firefox';
case 'windows':
return 'internet explorer,MicrosoftEdge,chrome,firefox';
default:
return 'chrome';
}
}
/**
* Default browser capabilities
* @param {*} browserName
*/
function defaultBrowserCapabilities(browserName) {
switch (browserName) {
// customize per browser
case 'firefox':
return {
maxInstances: 5,
browserName,
'moz:firefoxOptions': headless
? {
// flag to activate Firefox headless mode (see https://github.com/mozilla/geckodriver/blob/master/README.md#firefox-capabilities for more details about moz:firefoxOptions)
args: ['-headless']
}
: {}
};
case 'chrome':
return {
maxInstances: 5,
browserName,
'goog:chromeOptions': headless
? {
args: ['--headless', '--disable-gpu']
}
: {}
};
default:
return { maxInstances: 5, browserName };
}
}
@himildesai I see that you have only added ' reporters: ['browserstack']' in your conf file. Can you try specifying all the parameters, available here, https://github.com/browserstack/wdio-browserstack-reporter#configuration in your conf file?
I have the same error message with WebdriverIO v7.4.6 and wdio-browserstack-reporter v0.1.3:
ERROR @wdio/local-runner: Failed launching test session: TypeError: ReporterClass is not a constructor
at BaseReporter.initReporter (/Users/myuser/workspace/myproject/node_modules/@wdio/runner/build/reporter.js:157:20)
at Array.map (<anonymous>)
at new BaseReporter (/Users/myuser/workspace/myproject/node_modules/@wdio/runner/build/reporter.js:22:50)
at Runner.run (/Users/myuser/workspace/myproject/node_modules/@wdio/runner/build/index.js:77:26)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Extract of my package.json file:
"dependencies": {
// ...
"wdio-browserstack-reporter": "^0.1.3"
}
And my wdio.conf file:
reporters: ["browserstack"],
reporterOptions: {
browserstack: {
outputDir: "./reports/bs-results",
},
}
@himildesai With version 1.0.1, this issue is not reproductible.
{
"dependencies": {
"wdio-browserstack-reporter": "1.0.1"
}
}
Followed the instruction https://github.com/browserstack/wdio-browserstack-reporter/blob/master/README.md and I get the following error when I run wdio with the suggested config.
ERROR @wdio/local-runner: Failed launching test session: TypeError: ReporterClass is not a constructor at BaseReporter.initReporter (/home/apaliwal/Solution-engine-test/solution-engine-test-ui/node_modules/@wdio/runner/build/reporter.js:124:14) at Array.map (<anonymous>) at new BaseReporter (/home/apaliwal/Solution-engine-test/solution-engine-test-ui/node_modules/@wdio/runner/build/reporter.js:32:39) at Runner.run (/home/apaliwal/Solution-engine-test/solution-engine-test-ui/node_modules/@wdio/runner/build/index.js:77:21) at process.on.m (/home/apaliwal/Solution-engine-test/solution-engine-test-ui/node_modules/@wdio/local-runner/build/run.js:37:20) at process.emit (events.js:203:15) at process.EventEmitter.emit (domain.js:448:20) at emit (internal/child_process.js:832:12) at process._tickCallback (internal/process/next_tick.js:63:19)