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-testkit

v0.0.3

Published

A framework agnostic library for implementing Given, When, Then and parsing/validation of Gherkin feature files.

Downloads

6

Readme

Gherkin TestKit

A framework agnostic library for implementing Given, When, Then and parsing/validation of Gherkin feature files.

EXPERIMENTAL - DO NOT USE IN PRODUCTION

Overview

gherkin-testkit is a minimal, framework agnostic fork of jest-cucumber. Like Jest-Cucumber, it implements the Cucumber.js Gherkin AST parser. However, to keep the implementation light, gherkin-testkit does not implement a code generator used for hinting what code is needing to be implemented if missing. It is also missing the file system functionality of loadFeatures, loadFeature for compatibility with testing frameworks (such as WTR) that cannot access the filesystem using native fs calls.

Motivation

Jest-Cucumber is an excellent library for Jest which builds on top of Cucumber.js' Gherkin parser. The other alternative to Jest-Cucumber is Cucumber.js itself and Yadda, which uses its own syntax. Outside of these three libraries there are limited options. My need to work with Snowpack means I wanted to shift to Web Test Runner / RTL / Mocha / Chai / Sinon, which caused me to create this fork. Jest-Cucumber implements Jest calls in the feature-definition-creation.ts file - which is where I made function calls customizable by configuration. Without configuration, it defaults to work with Mocha's calls.

Roadmap

If possible, it would be ideal to have a single core for both Jest and other frameworks. Currently, the plan is to implement this core (or another one like it) with a test-runner-gherkin for WTR. The same may (or may not) be done for Jest.

Example usage for WTR

The following is an example step test file:

import { readFile } from '@web/test-runner-commands';
import { parseFeature, defineFeature, getGherkinTestKitConfiguration } from 'gherkin-testkit';
import { expect } from 'chai';

//@ts-ignore
readFile({ path: './CloneInit.feature' }).then((content) => {
  const feature = parseFeature(content, getGherkinTestKitConfiguration({}));
  defineFeature(feature, test => {
    test('Valid URL given for something that exists in localStorage', ({
      given,
      when,
      then
    }) => {
      given('a user wants to load a project already in localStorage', () => {
        expect(true).to.equal(true);
      });
  
      when('the user enters a URL that matches', () => {
        expect(true).to.equal(true);
      });
  
      then('the system renders what is in localStorage', () => {
        expect(true).to.equal(true);
      });
    });
  });
});

Step file code generation

To quickly generate step files, you can use the Jest-Cucumber code generator for vscode.