
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
gherkin-easy
Advanced tools
Minimalistic Gherkin testing for JavaScript
$ npm install gherkin-easy
# ./withdraw-cash.feature
Feature: Withdraw Cash
Scenario Outline: Withdraw cash from bank account
Given my account balance is <startingBalance> dollars
When I withdraw <withdrawAmount> dollars from my account
Then my account should have a remaining balance of <remainingBalance> dollars
Examples:
| startingBalance | withdrawAmount | remainingBalance |
| 100 | 50 | 50 |
| 100 | 0 | 100 |
| 100 | 1.25 | 98.75 |
| 1 | 0.50 | 0.50 |
| 1 | 5.00 | -4.00 |
// ./bank-account.js
class BankAccount {
constructor(balance = 0) {
this.balance = balance;
this.withdraw = this.withdraw.bind(this);
}
withdraw(amt = 0) {
this.balance = this.balance - amt;
return amt;
}
getBalance() {
return this.balance;
}
}
module.exports = BankAccount;
// ./__tests__/withdraw-cash-test.js
const FeatureTest = require('gherkin-easy');
const BankAccount = require('../bank-account');
const featureTest = new FeatureTest('../withdraw-cash.feature');
featureTest.run(({ given, when, then, example }) => {
let account;
beforeAll(() => {
account = new BankAccount(example.startingBalance);
});
test(given, () => {
expect(account.getBalance()).toBe(example.startingBalance);
});
test(when, () => {
expect(account.withdraw(example.withdrawAmount)).toBe(example.withdrawAmount);
});
test(then, () => {
expect(account.getBalance()).toBe(example.remainingBalance);
});
});
$ jest
-->
PASS examples/__tests__/withdraw-cash-test.js
Feature: Withdraw Cash
Scenario: Withdraw cash from bank account | Example 1
✓ Given my account balance is 100 dollars (2ms)
✓ When I withdraw 50 dollars from my account
✓ Then my account should have a remaining balance of 50 dollars
Scenario: Withdraw cash from bank account | Example 2
✓ Given my account balance is 100 dollars
✓ When I withdraw 0 dollars from my account
✓ Then my account should have a remaining balance of 100 dollars (1ms)
Scenario: Withdraw cash from bank account | Example 3
✓ Given my account balance is 100 dollars
✓ When I withdraw 1.25 dollars from my account
✓ Then my account should have a remaining balance of 98.75 dollars (1ms)
Scenario: Withdraw cash from bank account | Example 4
✓ Given my account balance is 1 dollars
✓ When I withdraw 0.5 dollars from my account
✓ Then my account should have a remaining balance of 0.5 dollars
Scenario: Withdraw cash from bank account | Example 5
✓ Given my account balance is 1 dollars
✓ When I withdraw 5 dollars from my account
✓ Then my account should have a remaining balance of -4 dollars
FAQs
Minimalistic Gherkin testing for JavaScript
We found that gherkin-easy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.