JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q29605F
  • License MIT

A different way to write tests with Cypress

Package Exports

  • cypress-witch
  • cypress-witch/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cypress-witch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cypress-witch

A different way to test with Cypress

npm

cypress-witch is a test case automation library for Cypress. It makes your Cypress tests concise, structured and readable.

Features

  • test structure becomes identical to test case specification
  • test structure becomes readable and understandable by anyone
  • enhanced logging makes failing tests review blazing fast
  • can be easily integrated into existing workflow or code base
  • easily extendable

Installation

npm i cypress-witch

In your cypress/plugins/index.js :

import { plugins } from 'cypress-witch/lib/plugins';

module.exports = (on, config) => {
  on('task', {
    ...plugins,
  })
}

Usage

With cypress-witch test is defined with testCase and consists of precondition(s), step(s) and expectedResult(s).

testCase accepts 3 arguments:

  • title: string - test case title
  • body: () => void - test case body
  • hooks: () => void - optional - cypress hooks (before, beforeEach, after, afterEach)

Showcase wih example.cypress.io/todo

todo.spec.js

import { testCase, precondition, step, expectedResult } from 'cypress-witch';

testCase('User adds and edits new todo', {
  body: () => {
    const testData = {
      newTodo: 'Feed the cat',
      editedTodo: 'Feed the dog',
    };

    precondition('1: User is at cypress todo example', () => {
      cy.visit('https://example.cypress.io/todo');
    });

    step('1: User adds new todo', () => {
      cy.get('[data-test=new-todo]')
        .type(`${testData.newTodo}{enter}`);
    });

    expectedResult('New todo is added', () => {
      cy.get('.todo-list li')
        .last()
        .should('have.text', testData.newTodo);
    });

    step('2: User edits created todo', () => {
      cy.get('.todo-list li')
        .last()
        .dblclick()
        .clear()
        .type(`${testData.editedTodo}{enter}`);
    });

    expectedResult('Todo item is edited', () => {
      cy.get('.todo-list li')
        .last()
        .should('have.text', testData.editedTodo);
    });
  },
});

cypress run

cypress run

cypress open

cypress open