![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
cuked-zombie
Advanced tools
Use cucumber and zombie in your acceptance tests
Cucumber is the Javascript reference-implementation for Behaviour Driven Development. Cucumber allows you to write acceptance tests at a higher abstraction level than unit tests. Zombie is a headless browser written in node, based on Contextify and JSDOM.
Combined they are the best available system to acceptance test your web-application in a browser.
cuked-zombie bridges the small gap between this libraries. It provides an api to infect your native cucumber steps. Infected cucumber steps have new (zombie-)features:
other features:
npm install cuked-zombie
(this will install Zombie as well)
npm install grunt-cucumber
(this will install cucumber-js as well)
To use cucumber with zombie you need to infect your step definitions and create an infected world (a world that knows how to invoke zombie(s)).
grunt cucumber
For this example it is assumed that your features are stored in features/something.feature
. Your infected step definitions should be stored in files grouped by domain in: tests/js/cucumber/domain-step-definitions.js
. For example: tests/js/cucumber/database-step-definitions.js
includes all steps dealing with database stuff. Have a look at tests/files/my-blog for a full, working structure.
We need to create a native step definition for cucumber, which then infects the other step definitions and creates a new zombie world.
create the file: tests/js/cucumber/bootstrap.js
and fill in:
module.exports = function() {
var cucumberStep = this;
var cukedZombie = require('cuked-zombie');
var infected = cukedZombie.infect(cucumberStep, {
world: worldOptions
steps: {
dir: __dirname
}
});
};
with this bootstrap config cuked-zombie will search for all files in __dirname
(next to your bootstrap.js) with the glob: *-step-definitions.js
. These found step definitions are called "infected" because cuked-zombie adds cool (zombie-)features to them.
dir
should be an absolute path name, or something that glob() (from current pwd) and require() will find. So its best to use something relative to __dirname
Here are some examples for the worldOptions:
var worldOptions = {
cli: // path to your symfony command line interface,
domains: {
// os.hostname(): domain
'my-server-name': 'staging.my-blog.com'
},
cookies: [{
name: 'staging_access',
value: 'tokenU1V2pUK'
}]
};
If you don't want to switch per os.hostname()
you can provide a domain directly:
domain: 'staging.my-blog.com'
basically every cucumber step can be an infected step (they are backwards compatible, allthough doomed to die). Goto the tests/js/cucumber
directory and create a node module like: database-step-definitions.js
. The base content is just like this:
module.exports = function() {
this.Given(..., function(callback) {
};
}
You can paste the this.Given/When/Then()
statements from the cucumber-js runner cli output.
The easiest way is to run cucumber with the built in grunt task:
Gruntfile.js
grunt.loadNpmTasks('grunt-cucumber');
grunt.loadNpmTasks('cuked-zombie');
grunt.initConfig({
cucumberjs: {
// config for all features when called with: `grunt cucumber`
all: {
src: 'features',
options: {
steps: "tests/js/cucumber/bootstrap.js",
format: "pretty"
}
},
// config for single features when called with `grunt --filter some-feature`
features: {
src: 'features',
options: {
steps: "tests/js/cucumber/bootstrap.js",
format: "pretty"
}
}
}
});
This needs grunt-cucumber installed, because cuked-zombie will use this task to run cucumber internally.
use
grunt cucumber
to run all tests or:
grunt cucumber --filter post
to run just the post.feature
and post-admin.feature
.
FAQs
use cucumber and acceptance tests with zombie
The npm package cuked-zombie receives a total of 0 weekly downloads. As such, cuked-zombie popularity was classified as not popular.
We found that cuked-zombie 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.