Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Cucumber is a tool for running automated tests written in plain language. It allows you to write tests that anyone can understand, regardless of their technical knowledge. Cucumber supports Behavior Driven Development (BDD) and is used to bridge the communication gap between stakeholders and developers.
Writing Features in Gherkin
Cucumber uses Gherkin syntax to define test scenarios in plain language. This makes it easy for non-technical stakeholders to understand and contribute to the test cases.
Feature: User login
Scenario: Successful login
Given the user is on the login page
When the user enters valid credentials
Then the user should be redirected to the dashboard
Step Definitions
Step definitions are the actual code implementations of the steps defined in Gherkin. They link the plain language steps to executable code.
const { Given, When, Then } = require('@cucumber/cucumber');
Given('the user is on the login page', function () {
// code to navigate to login page
});
When('the user enters valid credentials', function () {
// code to enter credentials
});
Then('the user should be redirected to the dashboard', function () {
// code to check redirection
});
Hooks
Hooks allow you to run code before and after each scenario. This is useful for setting up and tearing down test environments.
const { Before, After } = require('@cucumber/cucumber');
Before(function () {
// code to run before each scenario
});
After(function () {
// code to run after each scenario
});
Data Tables
Data tables allow you to run the same scenario with multiple sets of data. This is useful for testing different input combinations.
Feature: User login
Scenario Outline: Successful login with multiple users
Given the user is on the login page
When the user enters <username> and <password>
Then the user should be redirected to the dashboard
Examples:
| username | password |
| user1 | pass1 |
| user2 | pass2 |
jest-cucumber is a library that allows you to use Cucumber's Gherkin syntax with Jest. It provides a way to write BDD-style tests using Jest as the test runner. Compared to Cucumber, jest-cucumber is more tightly integrated with Jest and may be easier to set up for projects already using Jest.
cypress-cucumber-preprocessor is a plugin for Cypress that allows you to write your tests in Gherkin syntax. It combines the power of Cypress for end-to-end testing with the readability of Cucumber. This package is ideal for teams that prefer using Cypress for their testing needs but want to leverage BDD.
CodeceptJS is an end-to-end testing framework that supports BDD-style tests. It allows you to write tests in plain language and supports multiple test runners and helpers. Compared to Cucumber, CodeceptJS offers more flexibility in terms of test runners and integrations.
Cucumber brought (natively) to your JavaScript stack.
It can run basic fatures inside both Node.js and web browsers.
It still needs a lot of work. Only a few feature elements are supported at the moment.
And probably lots of other browsers.
Install the required dependencies:
$ npm link
$ node example/server.js
Then go to localhost:9797.
$ node_modules/.bin/jasmine-node spec
There is a common set of features shared between all cucumber implementations. Find more on the cucumber-features repository.
The official way of running them is through Cucumber-ruby and Aruba. Ruby and Bundler are required for this to work.
$ git submodule update --init
$ bundle
$ rm -rf doc; ARUBA_REPORT_DIR=doc cucumber features/cucumber-features -r features
You can then open the generated documentation:
$ open doc/features/cucumber-features/*.html # might open a lot of files ;)
In addition to that, Cucumber.js is able to run the features for itself too:
$ ./bin/cucumber.js features/cucumber-features -r features
There are a few other Cucumber.js-dependent features. Execute everything:
$ ./bin/cucumber.js
Alternatively, you can run everything with the help of Rake:
$ git submodule update --init
$ bundle
$ rake
You can display debug messages by setting the DEBUG_LEVEL environment variable. It goes from 1
to 5
. 5
will diplay everything, 1
will only print out the critical things.
$ DEBUG_LEVEL=5 ./bin/cucumber.js
It even works with Aruba:
$ rm -rf doc; DEBUG_LEVEL=5 ARUBA_REPORT_DIR=doc cucumber features/cucumber-features -r features
$ open doc/features/cucumber-features/*.html # you'll see debug messages in Aruba-generated docs
[0.2.1]
FAQs
The official JavaScript implementation of Cucumber.
The npm package cucumber receives a total of 180,371 weekly downloads. As such, cucumber popularity was classified as popular.
We found that cucumber demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.