Install and run #cucumber/cucumber in Node.JS - node.js

We want to use Cucumber in our Node.JS project. It's probably a pretty basic question but I'm following the Cucumber tutorial and I'm getting stuck at the part where you have to run Cucumber in order to test if everything works. How do I run the new Cucumber (#cucumber/cucumber) package? I think that my issue is related to the package change, which is now /#cucumber/cucumber instead of just cucumber. The command ./node_modules/.bin/cucumber-js -f node_modules/cucumber-pretty doesn't work. Furtermore, what does -f means?

Related

Using cucumber with cypress

Can anyone help me getting Cucumber to work with Cypress? Absolutely every guide I can find has this step in the setup:
X.
Add the relevant configurations to your Cypress environment files accordingly.
Under plugins/Index.JS file add the following:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
However, my project doesn't HAVE a cypress/plugins/index.js file. It DOES, however, have a cypress/plugins/index.ts file. I thought TypeScript was the going standard for Cypress, and not JavaScript?
The code above gives me errors on "require" (TS2591: Cannot find name 'require'), "module" (TS2591: Cannot find name 'module') and the parameters "on" and "config".
Apparently, the index.ts file WAS index.js once, since this is still included in the file:
// This example plugins/index.js can be used to load plugins
But obviously something is wrong here. But how come apparently no one else on the "entire internet" have had this problem? ( :-) )
To keep on trying, I skipped this part - also since I read some hints that it isn't longer necessary (not sure, though).
I also added this dependency to the project pom.xml:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-cypress</artifactId>
<version>5.7.0</version>
</dependency>
Then did the npm installs, maven clean install, refresh etc. etc., and creted a test.feature file in the /integration folder.
It seems that IntelliJ reconizes the file as a Cucumber feature file, because I get the option to run both the feature and the test inside.
However, that just gives me the following error when the feature tries to run:
Error: Could not find or load main class cucumber.cli.Main
Caused by: java.lang.ClassNotFoundException: cucumber.cli.Main
Figuring it was due to the cucumber.cli.Main missing in the run config, I opened it and saw that it wasn't. Nor was it working:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/ib9ZT.png
(The "cucumber" part of the line is makred red in "Main class".)
Changing this to " io.cucumber.core.cli.main" (which I believe is newer?) didn't help.
The last step I've tried is installing the Cucumber Js plugin in the plugin browser. Didn't seem to do any difference.
I'm afraid to try much more, since in my experience messing around too much with maven is likely to ruin any project to the point of me just having to scratch it and start over again.
Have you looked at https://github.com/TheBrainFamily/cypress-cucumber-typescript-example/?
It seems that you can use Cypress in Typescript but still define the plugins with JavaScript. That is you should convert your plugins.ts to plugins.js and everything should work as expected.
When you mentioned pom.xml, it must mean you are trying to set up Cypress and run in a Maven build.
You should first set up Cypress the node.js way first using npm install -D cypress#<an older version> because npm i -D cypress will install cypress 10 for you. Then after that, follow the steps in the link shared by #https://stackoverflow.com/users/5389127/ga%c3%abl-j to set up Cucumber for the older versions of cypress but use this for the later version of cypress.
You can set the repo up in maven using this article in this answer.
For a comprehensive guide on how to use Cypress, you can checkout this youtube link

Cucumber Js - How to run the features [Windows]

I'm trying to learn cucumber and so far got a grip on installing nodejs, cucumber, creating package.json, storing features files and steps. But when I'm trying to run using windows command prompt, I'm getting the below shown error.
project structure
features
- example.feature
- step_definitions
- steps.js
- support (nothing here yet)
node_modules (cucumber installed locally)
package.json
I started executing commands from the bin folder to ensure cucumberjs works and it echo'd out the version number 3.1.0
C:\Test Project\node_modules\.bin>cucumberjs -v
and then began to run the feature file
C:\Test Project\node_modules\.bin>cucumberjs "C:\Test Project\features\example.feature"
and it errors here
Note: If i install the cucumber globally then it works, this error happens when I install cucumber locally
Any help pointing out where I'm going wrong will be much appreciated
I haven't figured out what's the reason behind the error but managed to run the features files by adding the following to the project package.json and running cli npm run cucumber
"scripts": {
"cucumber": "cucumberjs ./features"
},

broadleaf - failed to execute goal

I am following these easy steps https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally
but I am stuck at step 2 already ´mvn spring-boot:run´ gives me the following error:
Failed to execute goal on project boot-community-demo-admin: Could not resolve dependencies for project com-mycompany-community:boot-community-demo-admin:jar1.0.0-SNAPSHOT.
feels like the pom.xml is not correct.
I believe it's looking for mycompany-community which doesn't exist http://nexus.broadleafcommerce.org/nexus/content/groups/community-snapshots/com/
thank you
You Can run using the eclipse it will run successfully with out giving any errors. here is the link to run using eclipse
Link: https://www.broadleafcommerce.com/docs/core/current/getting-started/ide-setup/eclipse-setup
It Will Work Fine While Running Using Eclipse. I Also checked in my System it is working fine with eclipseIDE.
It looks like you need to follow step 1c in the docs to mvn install from the root of the project. Did you do that part?

Why when test fails jenkins still says success?

I have a MEAN project. Using Jenkins on an EC2 machine I build this using the following shell script:
npm install && PORT=8888 npm test
mocha returns 2 (number of failing tests) but still jenkins says:
Finished: SUCCESS.
If tests are failing I expect to see
Finished: FAILURE
Do you know why its not working fine?
You can:
Use a test runner like Karma, or
Tell Mocha to report in, for example, XUnit format, by passing Mocha the --reporter xunit flag. XUnit closely aligns with JUnit which Jenkins understands, or
Add in a custom reporter — mocha-jenkins-reporter is a decent option.
In the end I used a different solution: installed Jenkins Text Finder and if "expected - actual" is found in log (test failed), I let this plugin to mark the build as "Unstable".

Issue with Node-based Cordova Hook

I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.

Resources