npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gherkin-wrapper

v0.5.0

Published

A wrapper that allows any test runner to handle the gherkin format

Downloads

20

Readme

Gherkin wrapper

Make any test framework handle the Gherkin format.

Supported test runners :

  • Playwright 1.44.0 and above
  • Jest 29.7.0 and above

Usage

Given the following feature file:

# features/example.feature

Feature: Guess the word

  Scenario: Breaker joins a game
    Given the Maker has started a game with the word "silky"
    When the Breaker joins the Maker's game
    Then the Breaker must guess a word with 5 characters

For Playwright

// step-definitions/example.spec.ts

import { test as base } from "@playwright/test";
import GherkinWrapper from "gherkin-wrapper";

// Add fixtures
const test = base.extend<{value: string}>({
    value: async ({}, use) => {
        await use('go')
    }
})

// Build the wrapper
const wrapper = new GherkinWrapper.forPlaywright(test)

// Register step functions
wrapper.given(/the Maker has started a game with the word "(.*)"/, async ({ page, value }, { match }) => {
    // Do things ...
})
wrapper.when("the Maker starts a game", () => {...})
wrapper.then("the Maker waits for a Breaker to join", () => {...})

// Run tests 
wrapper.test('./features/example.feature')
npx playwright test

For Jest

// step-definitions/example.spec.ts

import GherkinWrapper from "gherkin-wrapper";

// Build the wrapper
const wrapper = new GherkinWrapper.forJest(test)

// Register step functions
wrapper.given(/the Maker has started a game with the word "(.*)"/, async ({ match }) => {
    // Do things ...
})
wrapper.when("the Maker starts a game", () => {...})
wrapper.then("the Maker waits for a Breaker to join", () => {...})

// Run tests 
wrapper.test('./features/example.feature')
npx jest

Motivation

Since I've learnt about the Gherkin format for test specs definitions, I couldn't find a way to use complexe test runners like the Playwright one with a gherkin support without loosing most of the features brought by the runner. Most of the time, it was "Cucumber + another test tool". But tools like Cucumber want to act as the test runner, hence restrincting the "other test tool" features.

I wanted something that allows you to use a given test runner at its full potential and makes it handle the Ghearkin format. So I made one!

Concept

It's basically a wrapper for your favorite test runner.

Just like with Cucumber, you define your steps using given, when and then methods provided by the wrapper. Then, you launch your tests the very same way you used to for your test runner. The wrapper will read the feature files and build the tests for the your runner to run.

Roadmap

  • [x] Wrapper for Playwright
  • [x] Wrapper for Jest
  • [x] Setup for hook effects
  • [x] Concurrency for Jest (hook effect)
  • [ ] Wrapper for Vitest
  • [ ] Hook presets
  • [ ] More hook effects