We have tried below steps:
on node command prompt we tried exciting below commands
Npm install -g cucumber
Also we tried
npm install -g protractor-cucumber
cucumber --version
Above command opening webstorm editor.
We have created feature file(feature/testfeature.feature)
Now to generate skeleton we tried running below command on cmd prompt.
Cucumber.js
It is opening webstorm editor
We are not able to see skeleton file
Could you please suggest if we are missing anything
We should be able to create skeleton file using npm command.
Thanks in advance.
If you have to generate Step definitions structure/skeleton in your console you have to run the protractor command
protractor your_conf.js
your conf.js should look like this -
exports.config = {
directConnect: true,
baseUrl: '',
capabilities: {
'browserName':
(process.env.TEST_BROWSER_NAME || 'firefox'),
'version':
(process.env.TEST_BROWSER_VERSION || 'ANY')
},
onPrepare: function () {
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
global.expect = chai.expect;
browser.manage().window().maximize();
},
setDefaultTimeout : 60 * 1000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [
'../Features/*.feature'
],
cucumberOpts: {
monochrome: true,
strict: true,
plugin: ["pretty"],
require: ['../StepDefinitions/*.js', '../Support/*.js']
}
};
Related
I've been searching and found some issues and implementations that seems to be deprecated, though I'm not sure (as I tried to implement them and failed).
If it still not clear, what I want to achieve is a command line like so:
Straight in command line or npm scripts, we'd use something like this:
node-sass --config sassconfig.json
In sassconfig.json, we'd have a code like the one below:
{
"outputStyle": "compressed",
"sourceMap": true
}
This setup would make it more elegant and straightforward, just like tsconfig.json.
Normally you dont render Sass manually with a npm command. Integrate Sass in your webserver and render it when the server starts and your watcher programm recognize changes in the code (nodemon, Webpack hot module, etc.)
Here is an example for an expressJs server:
https://stackoverflow.com/a/26277894/6564085
Let me quote swervos' answer from the link to save the snippet in this answer:
var connect = require('connect');
var sass = require('node-sass');
var srcPath = __dirname + '/sass';
var destPath = __dirname + '/public/styles';
var server = connect.createServer(
sass.middleware({
src: srcPath,
dest: destPath,
debug: true,
outputStyle: 'expanded',
prefix: '/styles'
}),
connect.static(__dirname + '/public')
);
If you want to use Webpack heres a webpack version:
https://stackoverflow.com/a/46059484/6564085
let me quote Arnelle Balane's for it.
{
test: /.scss$/,
use: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
use: [{
loader: 'css-loader'
}, {
loader: 'sass-loader',
options: {
outputStyle: 'expanded'
}
}]
})
}
More information here: https://www.npmjs.com/package/sass-loader
I'm using wdio to run tests. I reduced maxInstances to 1.But wdio logging indicates that it creates a new session before each spec file. How can i run all webdriver.io spec files in single browser session?Thank you in advance.
wdio.conf.js is:
exports.config = {
specs: ['./test/specs/**/*.js'],
maxInstances: 1,
capabilities: [{
maxInstances: 1,
browserName: 'chrome',
}],
sync: true,
logLevel: 'verbose',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: process.env.ROOT_URL,
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ['chromedriver'],
framework: 'mocha',
reporters: ['dot', 'spec', 'allure'],
mochaOpts: {
ui: 'bdd',
timeout: 99999999
},
}
Try this workaround. It actually works for me with webdriverio v4
List all of your specs in a single file. You can take advantage of autocomplete feature of the IDE you are using, e.g.
specs.js
require('./test/specs/test1');
require('./test/specs/test2');
// etc.
require('./test/specs/testN');
In your wdio.conf.js file, list the above spec.js file as the only spec, i.e.
wdio.conf.js
exports.config = {
specs: ['./test/specs/specs.js'],
// etc.
}
WebdriverIO will run each test file in a different session. To run them all in the same session, you'd need to put all your tests in the same file.
If you're finding yourself needing to run all your tests in the same session, perhaps you should re-work your tests... Maybe use WebdriverIO's "before" hook if you need to do a common set up, like logging in to a site.
I'm using Nightwatch JS to run my e2e tests with the Mocha runner.
I want to integrate an HTML reporter that with the suite.
I'm trying to use the nightwatch-html-reporter package. But as far as I understand there is a problem with the CLI commands (it's written in the Nightwatch docs that --reporter will not work when using mocha).
I also copied the code sample from nightwatch-html-reporter to my globals.js but it doesn't seem to work either.
The tests run but there is no output anywhere.
Here is my folder structure:
project
src
spec
e2e
globals
globals.js
tests
smoke
testFile.js
nightwatch.conf.js
Here is my conf file:
const seleniumServer = require('selenium-server-standalone-jar');
const chromeDriver = require('chromedriver');
module.exports = {
src_folders: ['src/spec/e2e/tests'],
output_folder: 'report',
page_objects_path: [
'src/spec/e2e/pageObjects'
],
globals_path: 'src/spec/e2e/globals/globals.js',
custom_commands_path: 'src/spec/e2e/customCommands',
selenium: {
start_process: true,
server_path: seleniumServer.path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromeDriver.path
}
},
test_runner: {
type: 'mocha',
options: {
ui: 'bdd',
reporter: 'list'
}
},
test_settings: {
default: {
launch_url: 'http://URL',
silent: true,
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: [
"--no-sandbox",
"start-fullscreen"
]
}
}
}
}
};
And here is my global.js file:
var HtmlReporter = require('nightwatch-html-reporter');
var reporter = new HtmlReporter({
openBrowser: true,
reportsDirectory: __dirname + '/reports'
});
module.exports = {
reporter: reporter.fn
};
I don't think it will work with nightwatch-html-reporter as it is probably not a mocha reporter (but correct me if I'm wrong).
You want to use built in or custom mocha reporters when using nightwatch with mocha.
You can use a custom mocha html reporter like mochawesome but you'll have to hack around a bit and I offer no guarantees as I only tested those hacks lightly.
Here are the instructions to use mochawesome
(tested with
"mocha": "^5.2.0",
"mochawesome": "^3.1.1",
"nightwatch": "^0.9.21")
npm install mochawesome
Modify mochawesome node_modules\mochawesome *.js files to require mocha-nightwatch instead of mocha. (See instructions/explanations towards the end of the answer)
Presuming you're using a nightwatch.conf.js, configure your test runner to the equivalent of
test_runner : {
type : "mocha",
options : {
ui : "bdd",
reporter : require("mochawesome") // Please observe that you can pass a custom report constructor function here, not just reporter names
}
}
Run tests and observe that you still see the default console reporter (spec) but that at the end of the run you also see an output like:
[mochawesome] Report HTML saved to C:\projects\myWebApp\mochawesome-report\mochawesome.html
Open the html report.
This solution is hackish and fragile because nightwatch comes with it's own version of mocha.
When you install nightwatch you will see in your node_modules a mocha-nightwatch folder. This is the mocha that is being used by nightwatch.
However mochawesome doesn't use mocha-nightwatch. If you look at node_modules\mochawsome\dist\mochawesome.js you will see lines of code like:
var Base = require('mocha/lib/reporters/base');
var Spec = require('mocha/lib/reporters/spec');
This means is requires mocha, not mocha-nightwatch.
Those lines should ideally be: require('mocha-nightwatch/...).
So please change them in all *.js files that need fixing.
You could also fork mochawesome and make them like that ;)
Debugging notes:
Try putting some additional console.logs in node_modules\mocha-nightwatch\lib\mocha.js in the Mocha.prototype.reporter function. That's how I figured out what's going on.
If you use Mocha you can always go with mochawsome: https://www.npmjs.com/package/mochawesome
I haven't tried it myself but it looks pretty neat.
I am following the step by step on https://www.npmjs.com/package/grunt-scss-lint
I have installed everything, and seems to be working fine when I type in Terminal 'scss-lint'.
However I want this to be running in Grunt
Gruntfile:
scsslint: {
allFiles: [
'src/scss/**/*.scss',
],
options: {
bundleExec: true,
config: '.scss-lint.yml',
reporterOutput: 'scss-lint-report.xml',
colorizeOutput: true
}
},
grunt.registerTask('default', ['js', 'html', 'scsslint',]);
so I type in grunt in terminal which will run the tasks and in terminal - this pops up:
Running "scsslint:allFiles" (scsslint) task
Running scss-lint on allFiles
Please make sure you have ruby installed: ruby -v
Install the scss-lint gem by running:
gem update --system && gem install scss-lint
Running through grunt does not work but typing scss-lint in terminal works.
I did the following message but this message does not disappear
Your problem is related to the bundleExec parameter. If you set it to true, the plugin will expect the gem to be installed via bundler.
Set it to false, and it will work.
scsslint: {
allFiles: [
'src/scss/**/*.scss',
],
options: {
bundleExec: false,
config: '.scss-lint.yml',
reporterOutput: 'scss-lint-report.xml',
colorizeOutput: true
}
},
grunt.registerTask('default', ['js', 'html', 'scsslint',]);
Bashing my head against the wall:
Add
"sinon" : "latest"
to my bower.json. Install it.
Add sinon to my karma server:
files: [
'vendor/assets/bower_components/sinon/lib/sinon.js',
]
Paste the demo expectation into my spec:
it("calls the original function", function () {
var callback = sinon.spy();
var proxy = once(callback);
proxy();
assert(callback.called);
});
and:
TypeError: 'undefined' is not a function (evaluating 'sinon.spy()')
Why is this? How do I install sinon? Why haven't they bothered with an installation section on their github page?
I came to the same issue, and did the following :
in a command prompt, navigate to the root of your project and type :
npm install karma-sinon --save-dev
then in your karma.conf.js file add the following:
frameworks: ['jasmine', 'sinon']
It worked for me