How to resolve mochawesome reports in webdriver.io framework getting error TypeError: ReporterClass is not a constructor - webdriver-io

I have added the below dev dependencies for mochawesome reports in my webdriver.io framework.
"wdio-dot-reporter": "0.0.10",
"wdio-mochawesome-reporter": "^4.0.0"
My wdio.conf file looks like below
reporters: [
'dot',
[
'mochawesome',
{
outputDir: './Results',
},
],
],
When I am trying to run my tests getting the below error:
[0-0] 2021-12-24T09:20:57.498Z ERROR #wdio/local-runner: Failed launching test session: TypeError: ReporterClass is not a constructor
at BaseReporter.initReporter (/Users/id856795/myproximus-rn/node_modules/#wdio/runner/build/reporter.js:101:20)
at Array.map (<anonymous>)
at new BaseReporter (/Users/id856795/myproximus-rn/node_modules/#wdio/runner/build/reporter.js:21:50)
at Runner.run (/Users/id856795/myproximus-rn/node_modules/#wdio/runner/build/index.js:45:26)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
/Users/id856795/myproximus-rn/node_modules/#wdio/cli/build/interface.js:127
throw new Error('Could not find job');
^
Error: Could not find job

Related

CoreUi - why nightwatch cannot run e2e tests?

I want to start working with CoreUi Admin template and create project containing unit and e2e testing.
In the begining, I install CoreUi like shown in documentation:
git clone https://github.com/coreui/coreui-free-vue-admin-template.git CoreUI-Vue
cd CoreUI-Vue
npm install
Everything is ok. Now I want to run whole unit and e2e tests:
npm run test:unit
npm run test:e2e
All unit tests run properly. But when I run e2e test I got the following errors:
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
[BABEL] Note: The code generator has deoptimised the styling of /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#coreui/vue/dist/coreui-vue.common.js as it exceeds the max of 500KB.
WARNING Compiled with 2 warnings 2:47:38 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB) js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB) js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$ npm run test:e2e
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
WARNING Compiled with 2 warnings 3:06:39 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB)
js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)
js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I work on wsl2 and Debian. My node.js version is v13.14.0 and npm is 7.12.1. I installed chromedriver in version: ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) and last stable google chrome: google-chrome-stable 90.0.4430.212-1
What do I miss? Where could be the cause of the error in running e2e tests?
#UPDATE: I put the configuration of Nightwatch.conf.json:
// http://nightwatchjs.org/gettingstarted#settings-file
const path = require('path')
const deepmerge = require('deepmerge')
const chromedriver = require('chromedriver')
// user may have not installed geckodriver
let geckodriver = {}
try {
geckodriver = require('geckodriver')
} catch (e) {}
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
const chromeArgs = []
const geckoArgs = []
if (startHeadless) {
chromeArgs.push('headless')
geckoArgs.push('--headless')
}
const defaultSettings = {
src_folders: ['tests/e2e/specs'],
output_folder: 'tests/e2e/reports',
page_objects_path: 'tests/e2e/page-objects',
custom_assertions_path: 'tests/e2e/custom-assertions',
custom_commands_path: 'tests/e2e/custom-commands',
globals_path: path.resolve('tests/e2e/globals.js'),
test_workers: concurrentMode,
test_settings: {
default: {
detailed_output: !concurrentMode,
launch_url: '${VUE_DEV_SERVER_URL}'
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
w3c: false,
args: chromeArgs
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: geckoArgs
}
}
},
webdriver: useSelenium ? {} : {
server_path: geckodriver.path,
port: 4444
}
}
}
}
const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
function adaptUserSettings (settings) {
// The path to nightwatch external globals file needs to be made absolute
// if it is supplied in an additional config file, due to merging of config files
if (settings.globals_path) {
settings.globals_path = path.resolve(settings.globals_path)
}
return settings
}
function webdriverServerSettings () {
if (useSelenium) {
return {
selenium: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: require('selenium-server').path,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver': geckodriver.path
}
}
}
}
return {
webdriver: {
start_process: true,
port: 9515,
server_path: chromedriver.path
}
}
}
Version mismatch of chromedriver and chrome is the most common reason of e2e failing like this.
ChromeDriver 2.41 supports Chrome v67-69
your google-chrome-stable 90.0.4430 needs ChromeDriver 90.0.4430

How to fix 'STACK: ReferenceError: [BABEL]' at running jest tests

at running npm test i get the following error for every existing typescript class.
im using vue, jest
STACK: ReferenceError: [BABEL] ... Unknown option: base.cwd. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`

Implement cucmber with protracor test

I have tried to implement very simple cucumber with protractor example ,but get errors in feature file ,Here is my code
i'm useing node version v6.10.2 , protractor version Version 5.1.1 and cucumber version 2.4.0
protractor.conf.js file
var prefix = 'src/test/javascript/'.replace(/[^/]+/g,'..');
exports.config = {
seleniumServerJar: prefix + 'node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar',
chromeDriver: prefix + 'node_modules/protractor/selenium/chromedriver',
allScriptsTimeout: 20000,
frameworkPath: require.resolve('protractor-cucumber-framework'),
directConnect: true,
baseUrl: 'http://localhost:8099/',
cucumberOpts: {
require: 'step_definitions/stepDefinitions.js',
format: 'summary'
},
specs: [
'features/*.feature'
]
};
the feature file that get error
Feature: Running Protractor and Cucumber
Scenario: Protractor and Cucumber Test
Given I go to home page
the stepDefinition js file
module.exports = function() {
this.Given(/^I go to home page$/, function(site, callback) {
browser.get(site)
.then(callback);
});
}
but when i going to run by $ gulp protractor I get the following error
[16:01:21] Using gulpfile ~/git/adap_gateway/gulpfile.js
[16:01:21] Starting 'protractor'...
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
[launcher] Error: /home/ali/git/adap_gateway/src/test/javascript/features
/attack.feature:1
(function (exports, require, module, __filename, __dirname) { Feature:
Running Protractor and Cucumber
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/ali/git/adap_gateway/node_modules/jasmine/lib/jasmine.js:71:5
[launcher] Process exited with error code 100
[16:01:21] gulp-notify: [JHipster Gulp Build] Error: protractor exited
with code 100
[16:01:22] Finished 'protractor' after 936 ms
[16:01:22] E2E Tests failed
Can anyone please help me to fix the error?
Maybe you could try to set the framework property as 'custom' instead of requiring cucumber-protractor-framework.
I'm using the same stack and this is my configuration:
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
Hope this will help you.

Protractor : ERROR - Unable to start a WebDriver session

I wrote test cases three months back at that time they worked fine now i want to run those test cases in another system so i did basic setup. When i try to run protractor test case now they are failing with 'Unable to start a WebDriver session'. I have tried so many solutions but they didn't work for me.
Here i am attaching my protractor.conf.js file and error details.
protractor.conf.js
'use strict';
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
baseUrl: 'http://localhost:' + (process.env.PORT || '3036'),
chromeOnly: true,
// To get the maximimum test screen size
onPrepare: function() {
browser.driver.manage().window().maximize();
},
// list of files / patterns to load in the browser
specs: [
'e2e/attributeSection/search_spec.js', 'e2e/attributeSection/create_spec.js',
'e2e/attributeSection/edit_spec.js', 'e2e/attribute/search_spec.js',
'e2e/attribute/create_spec.js', 'e2e/attribute/edit_spec.js',
'e2e/classification/search_spec.js', 'e2e/classification/create_spec.js',
'e2e/classification/edit_spec.js', 'e2e/classificationGroup/create_spec.js',
'e2e/classificationGroup/edit_spec.js'
],
exclude: [],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
args: [],
extensions: [],
}
},
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 60000
}
};
Error in console
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.
C:\Users\Cronj- 4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1552:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:155:22)
at Function.webdriver.WebDriver.createSession (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:129:30)
at [object Object].Builder.build (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:416:22)
at [object Object].DriverProvider.getNewDriver (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.js:38:7)
at [object Object].Runner.createBrowser (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:180:37)
at C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:257:21
at _fulfilled (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
Could anyone help me out? Thanks in advance
I believe the "chromeOnly" option got deprecated in v2.0.0.
chromeOnly: true,
This used to mean use "direct" mode without a selenium server. But since both firefox and chrome support direct mode, the property was renamed to "directConnect". So change that line to:
directConnect: true,
In this mode you don't need a selenium server, so you can drop the seleniumAddress property which is just confusing folks.
See https://github.com/angular/protractor/pull/1933/files
I ran webdriver-manager start in one command prompt and protractor in another command prompt then only test cases started running

What line is causing this Protractor error?

Is there a way for Protractor to show in the console log what line the error occurred on? I just get this type of message:
Message:
Failed: Cannot call method 'click' of undefined
Stack:
Error: Failed: Cannot call method 'click' of undefined
at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:104:16
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
1 spec, 1 failure
It's hard to figure out if I have so many click commands. I'm running Protractor 1.8.0.
Here is my protractor.conf.js :
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://11.111.1.11:4444/wd/hub',
multiCapabilities: [{
'browserName': 'chrome',
'chromeOptions': {
args: ['--test-type']
}
}],
specs: ['./tests/my_test/*_spec.js'],
onPrepare: function(){
global.EC = protractor.ExpectedConditions;
browser.manage().window().maximize();
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
filePrefix: 'tests_xmloutput',
savePath: './test_results_report'
}));
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
The complete error message would be:
Failures:
1) test name description
Message:
Failed: Cannot call method 'click' of undefined
Stack:
Error: Failed: Cannot call method 'click' of undefined
at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:104:16
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
1 spec, 1 failure
Finished in 3.206 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
The content of the spec file/test would be:
HeaderNavigationPartialPage.myAppButton.click();
LeftNavigationPartialPage.myAppToolsLink.ERROR-ON-PURPOSE.click();
browser.wait(EC.elementToBeClickable(LeftNavigationPartialPage.myAppSearchLink), 10000);
LeftNavigationPartialPage.myAppSearchLink.click();
Here is a related issue at jasminewd project that protractor uses under-the-hood:
Stack traces for Jasmine2 don't include asynchronous events
The issue is now fixed, with jasmine upgrade to >=2.3.1.
What you should do is to upgrade protractor to >=2.1.0.
Old answer:
As a workaround, get back to jasmine 1.x:
exports.config = {
framework: 'jasmine',
...
}