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 write tests with Cypress
cypress-witch makes your Cypress tests concise, structured and readable.
Installation
npm i cypress-witchIn your cypress/plugins/index.js :
import { plugins } from 'cypress-witch/lib/plugins';
module.exports = (on, config) => {
on('task', {
...plugins,
})
}Showcase
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 open
