I can run the tests from the command line using
> ./node_modules/.bin/wdio wdio.conf.js
But if I try to run this from IntelliJ's run/debug configuration I get various different errors.
Featurefile or directory: /path_to_my_feature_file/myfeature.feature
Cucumber.js arguments: wdio.conf.js
Executable path: /path_to_my_project/node_modules/.bin/wdio
gives me
more than one config file specified
If I remove the Cucumber Arguments, it just runs indefinitely. If I stop it running I get the error
Failed loading configuration file
It looks like there's some kind of issue with loading the config file, but I don't know how to fix it. Any suggestions? wdio.conf.js exists and is in the project root.
WebStorm doesn't provide any special support for wdio test runner. But you can still run/debug the tests using Node.js run configuration like the following:
But this doesn't work out of the box due to problems related to using non-tty environment (Node.js run console in IDEA is non-tty). As a workaround, please try commenting out if (process.stdin.isTTY) and else branch in node_modules\webdriverio\build\lib\cli.js:
//if (process.stdin.isTTY) {
launch();
/*
} else {
var stdinData = '';
/!*
* get a list of spec files to run from stdin, overriding any other
* configuration suite or specs.
*!/
var stdin = process.openStdin();
stdin.setEncoding('utf8');
stdin.on('data', function (data) {
stdinData += data;
});
stdin.on('end', function () {
if (stdinData.length > 0) {
args['specs'] = stdinData.trim().split(/\r?\n/);
}
launch();
});
}*/
see WEB-31745
To get this to work with webdriverio v5 and higher you need to set in the debug configurations screen above
the path to the runner as the javascript file to execute:
node_modules#wdio\cli\bin\wdio.js
and the conf file as the application parameters:
wdio.conf.js
Related
My app is a node.js app which I can run through command line using: npm test inside the working directory. In WebStorm, I created a new configuration that looks like this:
Node interpreter: /usr/local/bin/npm
Node parameters: test
Working directory ~/dev/project
When I hit the run button, I get the correct output:
/usr/loca/bin/npm test
> app#1.0.0 test ~/dev/project
something else
Process finished with exit code 0
But since I have breakpoints set, it should have stopped on a breakpoint instead of getting to the Process finished part. I set my code to be pretty simple just so I can test breakpoints, so it looks like this:
"use strict";
let foo = false; (breakpoint)
let bar = true;
if (foo === bar) { (breakpoint)
console.log('something');
} else {
console.log('something else'); (breakpoint)
}
process.exit(1);
I also tried to make this work through command line. In my site settings, I set my Built-in server to port 12345. Can accept external connections, and allow unsigned requests.
when I run it through command line, I use:
npm --debug-brk=12345 test
I get the same result: it runs all the way to the exit point without stopping on the breakpoints.
Any ideas what I need to do to get this to work?
/usr/local/bin/npm is definitely not a Node interpreter, it's NPM package manager that is a Node.js application itself (i.e. it's run with Node.js interpreter). And test is a name of npm script, not a Node.js parameter.
If you like to debug your .js file that is run via npm test, you need to modify your npm script to include the debug options and then use NPM run configuration for debugging. Or, just create a Node.js configuration, set a valid path to Node.js execuitable there (/usr/bin/node or whatever it looks like on your system), then specify your .js file as JavaScript file:. See https://blog.jetbrains.com/webstorm/2017/09/debugging-node-js-apps-in-webstorm for more info
I have inherited a project running gulp+nodejs. I am trying to use IntelliJ in Windows as my IDE.
If I set my runtime configuration to use "node.js" as its type, I have no problem hitting breakpoints and debugging. However, if I use "gulp.js" as the run type, breakpoints are ignored (and I can essentially never debug). I also tried using Node.js configuration and setting the JS file to node_modules/gulp/bin/gulp.js instead of server/run.js . This seems to have the exact same problem.
Any thoughts on how I could fix this?
Gulp run configuration is not supposed to be used for Node application debugging - it was designed to run/debug Gulp tasks. To debug your Node.js application, you need to create a Node.js Run configuration and specify the .js file generated by Gulp build as a file to debug.
If you still prefer using Gulp to start your server, make sure that it is started with -debug-brk and then use Node.js Remote run configuration to attach the debugger.
Like:
var gulp = require('gulp');
var exec = require('child_process').exec;
gulp.task('server', function (cb) {
exec('node --debug-brk=5858 app.js', function (err, stdout, stderr) {
...
run your server task, then create Node.js Remote run configuration and hit Debug
I am trying to configure Protractor on Jenkins for CTI.... I have already setup Protractor along with Jasmine and trying to get it integrated with Jenkins.
I have gone through several links & blogs on internet but none seem to be helpful in providing detailed information on how to get the Protractor configured with Jenkins.
Any help or pointing towards the right blog or video will be really appreciated. Thanks
#Vishal
Please find the below snippet you can add as grunt task.
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
exec: {
protractorRunAppsTest: {
cmd: 'C:\\Program Files\\nodejs\\node.exe C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\protractor\\built\\cli.js C:\\Jenkins\\workspace\\test\\conf.js'
}
},
server: {
port:3000,
base: ['app']
},
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('server', 'Start node server', function() {
grunt.log.writeln('Started server on port 3000');
require('./app.js');
});
grunt.registerTask('runAppsTest', ['exec:protractorRunAppsTest']);
};
Save the above code as Gruntfile.js
Make sure this is in the workspace folder for jenkins.
In Jenkins job add the 'Build' Section (i am assuming Jenkins is windows server)
add "Execute Windows Batch Command" and add the below content to the text field there.
cd %WORKSPACE%
grunt server runAppsData || exit 0
I hope this would work for you. Please try and let me know.
Consider rating my answer.
#Vishal try to use grunt for doing the same. So that you can easily integrate the Jenkins job with grunt task details.
Just configure and register task with grunt.
Then use the grunt task to run in jenkins.
If you want i can provide more details.
What is the difference between nightwatch.conf.BASIC.js and
nightwatch.conf.js in nightwatch framework.
And what is basic requirement for setup nightwatch framework with
node js and selenium
There is no differences between nightwatch.conf.BASIC.js and nightwatch.conf.js.
You have just to know 5 things:
You can name your config file as you want (nightwatch.conf.BASIC.js, nightwatch.json, nightwatch.conf.js or anything.json or anything.js)
You can have more than 1 config file per project.
When you put your Nightwatch configuration in a file named nightwatch.json or nightwatch.conf.js you don't need to say which configuration file should be used since
A nightwatch.conf.js file or a nightwatch.json file will also be loaded by default, if found.
Just keep in mind that:
The nightwatch.conf.js always takes precedence over
nightwatch.json if both are present.
In this case, you can launch your tests like this:
$> nightwatch
When you put your Nightwatch configuration in an other file, you must tell Nightwatch where are the configurations to use. In this case you need to write your tests like this (for example in Node.js):
module.exports = (function(settings) {
//....
})(require('path/to.your/config/file'));
or
var config = require('path/to.your/config/file');
module.exports = {
//....
};
In this case, you need to specify which configuration file to take when launching tests:
$> nightwatch --config path/to.your/config/file
Since naming your config file nightwatch.conf.js or nightwatch.json doesn't change anything to Nightwatch, is there a reason to choose one and not the other?
Answer: Yes!
Why?: Sometimes you need to write a JavaScript code in your configuration file. In this case your file should be a .js file and not a .json file.
Example of use? When you have many environments to test, maybe you don't want to update many lines to change the same information. So you write a nightwatch.conf.js (The objective is to just change one line when you want to deactivate video instead of going to each environment in a .json file and make changes):
nightwatch_config = {
src_folders : [ "a/file/to/test" ],
selenium : {/*...*/},
common_capabilities: {/*...*/},
test_settings: {
default: {},
chrome: {desiredCapabilities: {browser: "chrome"}},
firefox: {desiredCapabilities: {browser: "firefox"}},
safari: {desiredCapabilities: {browser: "safari"}},
ie: {desiredCapabilities: {browser: "internet explorer"}}
}
};
for(var i in nightwatch_config.test_settings){
var config = nightwatch_config.test_settings[i];
for(var j in nightwatch_config.common_capabilities){
config['desiredCapabilities'][j][browserstack.video] = true;
}
}
module.exports = nightwatch_config;
So I have a file running in node which runs a local copy of PhantomJS as below shows:
phantom.casperPath = 'node_modules/casperjs';
phantom.injectJs('node_modules/casperjs/bin/bootstrap.js');
var casper = require('casper').create({
viewportSize: config.viewportSize
});
casper.test.begin('Runing tests here', 5, function suite(test) {
// Tests here
});
Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following error in my console:
CasperError: casper.test property is only available using the `casperjs test` command
The CasperJS docs mentions this too: http://docs.casperjs.org/en/latest/testing.html. My question is how do I run this Casper under this command in the above code so I can use these tests?
Thanks!
CasperError: casper.test property is only available using the casperjs test command
problem solved.
You have to include this line at the top of your script in your xyz.js, so that the .test property becomes true;
phantom.casperTest = true;
Then you should have no problem Launching from the terminal:
casperjs xyz.js
you can also call casperjs test xyz.js
For more info, check the doco here : http://docs.casperjs.org/en/latest/testing.html