1.2.10 • Published 2 years ago

cypress-witch v1.2.10

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

1.2.9

2 years ago

1.2.10

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago