Using cucumber with cypress - cucumber

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

Related

Webpack loading wrong version of Node Module for Angular project

I have a project in Angular 13. I want to use quillJS and I want to add tables so I tried to install quill-better-table in my project.
For some reason the package is not working. I used the web inspector and found this to be the issue:
ERROR TypeError: quill.keyboard.bindings.Backspace is undefined
The problem seems to be located at: quill_better_table_BetterTable quill-better-table.js:2979 and when I check the debugger I can see the line:
let thisBinding = quill.keyboard.bindings['Backspace'].pop();
quill.keyboard.bindings['Backspace'].splice(0, 1, thisBinding); // add Matchers to match and render quill-better-table for initialization
// or pasting
I found a github repo that had this issue fixed:
https://github.com/LosEcher/quill-better-table
The problem I'm running into is I dont know how to get that particular repo into my project. I have tried updating the current package and webpack continues to load the old one. I've tried clearing the npm cache and reinstalling the node packages.
I found this guide: https://whatapalaver.co.uk/npm-dependency which seems to indicate what I should do but I'm not quite npm literate enough to figure it out. Specifically, I dont know that I understand how to create the NPM link.
I'm looking for advice as to how to fix this package. I am going to be reading up on NPM link but I figured if there was another easier way to get this fixed then I would ask. I can load that repo into my node module folder, but I dont know how to make webpack reload the updated module.
Thanks in advance for the help, let me know what details I for got to add.

Error - ESLint: 7.32.0 ESLint couldn't find the config "standard" to extend from

We have a CircleCI Pipeline. We have a older version of eslint i.e. 5.10.0 which was around three years ago installed and now client wants to upgrade node version to 16 and upgrade related packages.
I have modified package.json file and changes eslint version from "eslint": "^5.10.0" to "eslint": "^7.10.0".
Now, while pushing changes on branch CircleCI test execution fails with the below error.:
Oops! Something went wrong! :(
ESLint: 7.32.0
ESLint couldn't find the config "standard" to extend from. Please check that the name of the config is correct.
The config "standard" was referenced from the config file in "/home/xxx/xxx/.eslintrc.yml".
I have googled for this issue but did not find the proper solution for this.
I have tried to
Removed .eslintrc.yml file by guessing that it can be created automatically.
Try to run the command yarn run eslint --init inside package.json under script tag
"scripts": {
"test": "yarn run eslint --init && yarn lint && yarn flow && yarn jest",
}
But here, CircleCI pipeline is used so eslint --init command will ask question
How would you like to use ESLint?
We don't have any provision in CircleCI during automated file and test execution to provide any answer.
I had a similar case, where this error was due to my eslint version being too new compared to the one required by standard.
Here are some steps you can try to verify whether that's the case for you as well:
Locally in your project, run npm init #eslint/config (will ask you some questions and generate a new .eslint.{js|yml|json} out of it)
When asked "Which style guide do you want to follow?" reply standard
at this point, you should see something on the line of
The style guide "standard" requires eslint#^7.12.1. You are currently using eslint#{version}
Do you want to downgrade?
choosing "No" will warn you as follow and cause the error you mentioned when trying to execute linting.
Note: it might not work since ESLint's version is mismatched with the standard config
In my case the eslint version was differing by major (8.11.0) which makes it more obvious, but it looks very similar to what you have too.
If by this point you figured that's indeed the issue, here are some alternatives that might help:
Downgrade eslint (easy one but won't work in the long run if you like your dependencies to be up-to-date)
Switch to another style guide which doesn't have this limitation with eslint version (eg. airbnb or google's are suggested by the config setup)
Switch to using standard directly instead of going through eslint
I am no expert in js world, so please feel free to point out anything I missed

cucumber-js parse error when run on Jenkins

I am trying to setup a jenkins pipeline step to runs some test scenarios using cucumber-js but I am getting an error back from the build as follows:
Error: Parse error in 'e2e/definitions/login.js': (1:1): expected:
#EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'const { Given, When, Then } = require('cucumber');'
The command being run in the pipeline step is as follows:
cucumber-js e2e/features/**/*.feature --require e2e/**/*.js
The opening lines of the login.js file the error is referencing are:
const { Given, When, Then } = require('cucumber');
const { Selector } = require('testcafe');
I'm wondering if this has something to do with nodejs version differences, as I am running 8.11.2 on my machine and dont see these errors, on Jenkins we are running 10.5.0
Does anyone know what the problem could be and point me in the right direction please?
Thanks
Likely you have this problem because the glob pattern specified after the --require pattern isn't resolved to real file names, but on your Jenkins it does. Try to wrap e2e/**/*.js in double quotes:
cucumber-js e2e/features/**/*.feature --require "e2e/**/*.js"
The error you're getting is a Gherkin parsing error, so I think cucumber is treating your step definition file as a Gherkin file (feature file). I would check which version of cucumber-js you're using locally versus the version that your using in CI. If the versions are different, your CI might be missing a bugfix or it might be using an different version of the CLI.
I also highly recommend setting up your local environment the same way as your CI (same version of node, pinned versions for your npm dependencies), it has saved me a lot of pain.

ERROR: package.js is undifined

I recently done some updates and added some packages based on recommendations from meteor
you know the usual If you notice problems related to these missing modules, consider running: meteor npm install ...
Problem now is that I get errors relating to the following
when I click to see which line is causing the issue, it's from var EJSON = Package.ejson.EJSON;
I don't know what this is therefore I am assuming I never messed with it during development.
any insight would be appreciated ...
EDIT: I went back through my commands, this issue started when I added meteor add ecmascript (solved one problem to open up another :))
Also as requested .meteor/packages
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
autopublish#1.0.7
less#2.7.11
twbs:bootstrap#3.3.6
fortawesome:fontawesome
jquery#1.11.10
okgrow:router-autoscroll
meteor-base#1.3.0
mobile-experience#1.0.5
mongo#1.4.2
blaze-html-templates#1.0.4
session#1.1.7
tracker#1.1.3
logging#1.1.19
reload#1.2.0
random#1.1.0
ejson#1.1.0
spacebars#1.0.12
check#1.3.0
standard-minifier-css#1.4.0
standard-minifier-js#2.3.1
shell-server#0.3.1
kadira:flow-router
kadira:blaze-layout
zimme:active-route
accounts-ui#1.3.0
accounts-password#1.5.0
dynamic-import#0.3.0
http#1.4.0
percolate:synced-cron
matb33:collection-hooks
reactive-var
ecmascript

Issues installing swiper.js (node.js/grunt noob)

Having issues getting swiper.js to work. Requires grunt/bower. I'm completely new to js generators and am only able to get through about half the walkthrough before running into issues.
When I type $grunt dist into terminal, I get the following response: -bash: dist: command not found
What step am I missing?
Followed the idangerous steps to the letter: http://www.idangero.us/sliders/swiper/plugins/scrollbar.php
I have most often see "X command not found" for one of the following reasons:
The project's Grunt dependencies aren't installed or aren't installed properly
Your Gruntfile is mis-configured or missing
To fix this, first make sure there is a package.json file in your project. This will tell the npm what dependencies the project has and install them accordingly (assuming the package.json file is also configured correctly).
Next, make sure you have installed grunt correctly.
If you're still having issues, open your Gruntfile and search for:
grunt.registerTask('dist
This will show where the "dist" task is being defined. If you for some reason don't find it, then there's your problem. If you do find it, then check the proceeding commands inside square brackets that look like this:
grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
'clean', 'dist-css', etc. are all other tasks defined in the Gruntfile, and there could be an issue with those as well.
If there's an issue with your package.json or Gruntfile, then trying re-installing the project with bower and repeat the above steps to ensure that it's not an issue on your end.
If it's not, then something is probably wrong with the author's source code.

Resources