Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Fluent, painless, and beautiful synchronous/asynchronous step definitions for Cucumber.js. Supports promises, generators, and async functions, powered by co.
Oh, and listen to some nice chill trap and artstep.
Note: v55555 works with Cucumber 0.9. For older versions of Cucumber (v0.4), please use v5555.
When creating step definitions for cucumber-js, I always feel like this:
It simply sucks. As of v0.4.8: Not so much anymore:
callback
function, the event queue is drained and Cucumber simply exits without reporting anything.this.
every time to define a single step.So I created some wrapper functions for them and then turn it into a library.
Returns a function that can be exported as a Cucumber steps definitions.
The returned function also has several methods, which can be used to define steps. These methods are all fluent, meaning that they all return the same function.
var steps = require('artstep')
module.exports = steps()
.Given(pattern, handler)
.When(pattern, handler)
.Then(pattern, handler)
.before(...tags, handler)
.after(...tags, handler)
.beforeAll(handler)
.afterAll(handler)
.around(handler)
Note: Both PascalCase and lowerCamelCase versions are available for all these methods.
A handler is:
A synchronous function. Handler will finish running immediately:
.Then('the title contains "..."', function(text) {
expect(this.subject.title).to.contain(text)
})
A function that returns a Promise:
.When('I select the $n song', function(n) {
n = parseInt(n, 10)
return driver.findElements(By.css('ul.music-list > li'))
.then(function(items) {
return items[n - 1].click()
})
})
In CoffeeScript, it looks very beautiful:
.When 'I select the $n song', (n) ->
n = parseInt(n, 10)
driver.findElements(By.css('ul.music-list > li')).then (items) ->
items[n - 1].click()
An ES6 generator function:
.When('I select the $n song', function*(n) {
n = parseInt(n, 10)
var items = yield driver.findElements(By.css('ul.music-list > li'))
yield items[n - 1].click()
})
You can yield promises, generators, thunks, arrays, or objects. Then the resolved value will be given back unto you. This is possible because of the amazing co library.
An ES7 asynchronous function:
.When('I select the $n song', async function(n) {
n = parseInt(n, 10)
var items = await driver.findElements(By.css('ul.music-list > li'))
await items[n - 1].click()
})
An async function from asyncawait, which makes this CoffeeScript steps definitions extremely beautiful!
.When 'I select the $n song', async ->
n = parseInt(n, 10)
items = await driver.findElements(By.css('ul.music-list > li'))
await items[n - 1].click()
null
, false
or undefined
. In this case, the steps will be marked as "pending."
The semantic of around hooks changed a little bit. It passes a function that, when called, runs the scenario, and returns a Promise which will be resolved when the scenario finishes executing.
That promise can be yielded.
ES5 + Promises:
.Around(function(run) {
return stuffBefore()
.then(run)
.then(stuffAfter)
})
ES6 Generators:
.Around(function*(run) {
var start = Date.now()
yield run()
var finish = Date.now()
console.log('It took', finish - start, 'ms')
})
ES7 Async Functions:
.Around(async function(run) {
var start = Date.now()
await run()
var finish = Date.now()
console.log('It took', finish - start, 'ms')
})
FAQs
Beautiful step definitions for Cucumber.js
We found that artstep 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.