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

@autometa/cucumber-transformer-jest

v0.5.6

Published

Convert Cucumber .feature files into Autometa cucumber tests with jest

Downloads

693

Readme

Introduction

Autometa Cucumber Runner is a wrapper for multiple established test runners like jest and vitest that enables support for testing .feature files.

Full Documentation

Features

  • Utilize you or your teams favorite testing framework with Cucumber
  • Steps are defined globally and scenarios are self assembling
  • Steps can be overridden for specific features or scenarios with edge behavior
  • Per-Scenario dependency injection of tester-defined classes.
  • Cucumber expressions
  • Extensive handling of data tables
  • CommonJs and ESM compatible

Install

npm add -D @autometa/cucumber-runner
yarn add -D @autometa/cucumber-runner
pnpm add -D @autometa/cucumber-runner

Quick Start

Configure

To begin, add *.feature.ts as a test file pattern to your test library config if needed. Also, add autometa.config.ts to the setup files option

import { defineConfig } from 'vitest/config'

defineConfig({
  ...
  setupFiles: ['autometa.config.ts']
  include: ['**/*.{test,spec,feature}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
  ...
})
export default {
  ...
  setupFilesAfterEnv: ['autometa.config.ts']
  testMatch: ['**/?(*.)+(spec|test|feature).[jt]s?(x)']
  ...
}

Next, create the autometa.config.ts. To use globally available step files, add a globals option, and provide the test functions of your test framework. It's also a good idea to import reflect-metadata from this file. reflect-metadata is a required dependency of this library.

import "reflect-metadata";
import { defineConfig } from "@autometa/cucumber-runner";
import { describe, test, beforeEach, beforeAll, afterEach, afterAll } from "vitest";

defineConfig({
  globals: "globals",
  runner: {
    name: "vitest",
    describe,
    test,
    beforeEach,
    beforeAll,
    afterEach,
    afterAll,
  },
});
import "reflect-metadata";
import { defineConfig } from "@autometa/cucumber-runner";

defineConfig({
  globals: "globals",
  runner: {
    name: "jest",
    describe,
    test,
    beforeEach,
    beforeAll,
    afterEach,
    afterAll,
  },
});

Use

Feature: A User Can Log In
  Background: Set up a new User
    Given a new registered User
      | username | name | age | password |
      | johnny5  | John | 45  | paS5091! |

  Scenario: A User logs in with valid credentials
    When they log in
     | username | password |
     | johnny5  | paS5091! |
    Then they see their profile

  Scenario: A User logs in with a bad password
      When they log in
     | username | password |
     | johnny5  | oops     |
    Then they are informed their password is incorrect
import { Given, When, Then, Feature, Before, Scenario } from "@autometa/cucumber-runner";
import { App } from "../src/app";

Before("Launch browser", async ({ world, myDriver }) => {
  world.page = await myDriver.start(process.env.API_URL);
});

Given("a new registered User", async (data: HTable, { world, httpClient }: App) => {
  const userDetails = data.json(0);
  await httpClient.createUser(userDetails);
});

When("they log in", async (userDetails: HTable, { world: { page } }: App) => {
  const { username, password } = userDetails.json(0);
  await page.logUserIn(username, password);
});

Then("they see their profile", async ({ world: { page } }: App) => {
  await page.verifyProfileOpen();
});

Then(
  "they are informed their {word} is incorrect",
  async (field: string, { world: { page } }: App) => {
    await page.verifyBadLoginField(field);
  }
);

Feature("../features/my-feature.feature");

// override Steps

Feature(() => {
  Given("a new registered User", async (data: HTable, { world: { page } }: App) => {
    const userDetails = data.json(0);
    await page.gotoRegistration();
    await page.registerWith(userDetails);
  });

  Scenario("A User logs in with a bad password", () => {
    Then("they are informed their password is incorrect", async ({ world: { page } }: App) => {
      await page.verifyBadPassword();
    });
  });
}, "../features/my-feature.feature");

// load multiple feature files

Feature("../features/my-feature.feature", "../features/my-other-feature.feature");