From 37ff1ce64e84b832559d2024bf47ac8b466bd840 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Wed, 11 Aug 2021 10:57:59 -0400 Subject: [PATCH] fix: add use and install sections --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c43cc2..456adf1 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,52 @@ CI | status [cy-spok-example](https://github.com/bahmutov/cy-spok-example) | ![cy-spok-example status](https://github.com/bahmutov/cy-spok-example/workflows/tests/badge.svg?branch=master) -See [cypress/integration/spec.js](cypress/integration/spec.js) +## Install + +``` +$ npm i -D cy-spok +``` + +## Use + +See [spok](https://github.com/thlorenz/spok#readme) docs + +```js +// in your Cypress spec file +import spok from 'cy-spok' + +const object = { + one: 1, + two: 2, + three: 3, + four: 4, + helloWorld: 'hello world', + anyNum: 999, + anotherNum: 888, + anArray: [1, 2], + anotherArray: [1, 2, 3], + anObject: {}, +} + +// using Spok +// https://github.com/thlorenz/spok#readme +cy.wrap(object, { timeout: 2000 }).should( + spok({ + $topic: 'spok-example', // optional + one: spok.ge(1), + two: 2, + three: spok.range(2, 6), + four: spok.lt(5), + helloWorld: spok.startsWith('hello'), + anyNum: spok.type('number'), + anotherNum: spok.number, + anArray: spok.array, + anObject: spok.ne(undefined), + }), +) +``` + +See [cypress/integration/spec.js](cypress/integration/spec.js) here and in the [cy-spok-example](https://github.com/bahmutov/cy-spok-example) repo. ![Spok in action](img/cy-spok.gif)