Skip to content

joshuajtward/cypress-spok-command

Repository files navigation

NPM

tests

cypress-spok-command

This repo is a wrapper around cy-spok, moving it into a custom command with the help of a string-to-function map. The motivation for this is to make it easier to write spok assertions in Cypress, without having to import cy-spok in every file.

Installation

npm i -D cypress-spok-command
# or
yarn add -D cypress-spok-command

Usage

Add the following to your commands file (cypress/support/commands.js by default):

import spok from "cypress-spok-command";

Then inside a test you can immediately use the cy.spok() command:

cy.spok(target, matcher);

e.g.

it('matches with spok!', () => {
    cy.request('/someEndpoint').then((response) => {
        // this could also be loaded from a fixture
        const expectedResponse = {
            foo: 1
            bar: {
                a: 1,
                b: 2
            }
        }
        cy.spok(response.body.data, expectedResponse)
    })
})

Further examples

More examples can be found in the test suite for this package, under the cypress/intergration directory

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published