All Projects → bencompton → Jest Cucumber

bencompton / Jest Cucumber

Licence: apache-2.0
Execute Gherkin scenarios in Jest

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Jest Cucumber

Simple React App
Simple base app using react, react-router v4, hot-reload & sass.
Stars: ✭ 263 (-24.21%)
Mutual labels:  jest
Jest Playwright
Running tests using Jest & Playwright 🚀
Stars: ✭ 296 (-14.7%)
Mutual labels:  jest
Cucumber
A monorepo of common components - building blocks for implementing Cucumber in various languages.
Stars: ✭ 3,299 (+850.72%)
Mutual labels:  cucumber
Rxjs Marbles
An RxJS marble testing library for any test framework
Stars: ✭ 267 (-23.05%)
Mutual labels:  jest
Jest Puppeteer
Run your tests using Jest & Puppeteer 🎪✨
Stars: ✭ 3,267 (+841.5%)
Mutual labels:  jest
Front End
Operation Code's website
Stars: ✭ 301 (-13.26%)
Mutual labels:  jest
Bs Jest
BuckleScript bindings for Jest
Stars: ✭ 255 (-26.51%)
Mutual labels:  jest
Jest Mongodb
Jest preset for MongoDB in-memory server
Stars: ✭ 323 (-6.92%)
Mutual labels:  jest
Mockingoose
A Jest package for mocking mongoose models
Stars: ✭ 279 (-19.6%)
Mutual labels:  jest
Jest Junit
A Jest reporter that creates compatible junit xml files
Stars: ✭ 307 (-11.53%)
Mutual labels:  jest
React Native Navigation Redux Starter Kit
React Native Navigation(v2) Starter Kit with Redux, Saga, ESLint, Babel, Jest and Facebook SDK 😎
Stars: ✭ 271 (-21.9%)
Mutual labels:  jest
Snapguidist
Snapshot testing for React Styleguidist
Stars: ✭ 287 (-17.29%)
Mutual labels:  jest
Ebikes Lwc
Sample application for Lightning Web Components and Communities on Salesforce Platform. Part of the sample gallery. Retail use case. Get inspired and learn best practices.
Stars: ✭ 299 (-13.83%)
Mutual labels:  jest
Rockpack
Rockpack is a simple solution for creating React Application with Server Side Rendering, bundling, linting, testing within 5 minutes
Stars: ✭ 265 (-23.63%)
Mutual labels:  jest
Coderplanets web
the most sexiest community for developers, build with React, Mobx/MST, GraphQL, Styled-Components, Rxjs, Ramda ... and ❤️
Stars: ✭ 314 (-9.51%)
Mutual labels:  jest
N2ex
🌈 V2ex built with Nuxt.js (vue&ssr)
Stars: ✭ 260 (-25.07%)
Mutual labels:  jest
React Bolt
⚡ The most simple & robust boilerplate for your React projects.
Stars: ✭ 298 (-14.12%)
Mutual labels:  jest
Electron React Boilerplate
A Foundation for Scalable Cross-Platform Apps
Stars: ✭ 18,727 (+5296.83%)
Mutual labels:  jest
Sazerac
Data-driven unit testing for Jasmine, Mocha, and Jest
Stars: ✭ 322 (-7.2%)
Mutual labels:  jest
React Redux Boilerplate
Awesome React Redux Workflow Boilerplate with Webpack 4
Stars: ✭ 307 (-11.53%)
Mutual labels:  jest

Jest Cucumber

Execute Gherkin scenarios in Jest

Build Status Greenkeeper badge npm downloads

Cucumber Jest Demo

Overview

jest-cucumber is an alternative to Cucumber.js that runs on top on Jest. Instead of using describe and it blocks, you instead write a Jest test for each scenario, and then define Given, When, and Then step definitions inside of your Jest tests. jest-cucumber then allows you to link these Jest tests to your feature files and ensure that they always stay in sync.

Motivation

Jest is an excellent test runner with great features like parallel test execution, mocking, snapshots, code coverage, etc. If you're using VS Code, there's also a terrific Jest extension that allows you get realtime feedback as you're writing your tests and easily debug failing tests individually. Cucumber is a popular tool for doing Acceptance Test-Driven Development and creating business-readable executable specifications. This library aims to achieve the best of both worlds, and even run your unit tests and acceptance tests in the same test runner.

Getting Started

Install Jest Cucumber:

npm install jest-cucumber --save-dev

Add a Feature file:

Feature: Logging in

Scenario: Entering a correct password
    Given I have previously created a password
    When I enter my password correctly
    Then I should be granted access

Add the following to your Jest configuration:

  "testMatch": [
    "**/*.steps.js"
  ],

Add a step definition file that links to your feature file:

// logging-in.steps.js

import { defineFeature, loadFeature } from 'jest-cucumber';

const feature = loadFeature('features/LoggingIn.feature');

Add a Jest test for each scenario into your step definition file:

// logging-in.steps.js

import { defineFeature, loadFeature } from 'jest-cucumber';

const feature = loadFeature('features/LoggingIn.feature');

defineFeature(feature, test => {
  test('Entering a correct password', ({ given, when, then }) => {

  });
});

Add step definitions to your scenario Jest tests:

// logging-in.steps.js

import { loadFeature, defineFeature } from 'jest-cucumber';
import { PasswordValidator } from 'src/password-validator';

const feature = loadFeature('specs/features/basic-scenarios.feature');

defineFeature(feature, (test) => {
  let passwordValidator = new PasswordValidator();
  let accessGranted = false;

  beforeEach(() => {
    passwordValidator = new PasswordValidator();
  });

  test('Entering a correct password', ({ given, when, then }) => {
    given('I have previously created a password', () => {
      passwordValidator.setPassword('1234');
    });

    when('I enter my password correctly', () => {
      accessGranted = passwordValidator.validatePassword('1234');
    });

    then('I should be granted access', () => {
      expect(accessGranted).toBe(true);
    });
  });
});

Additional Documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].