npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-jest-adapter

v0.1.1

Published

Add jest style expect on top of chai to Cypress

Downloads

101,396

Readme

Jest assertions for Cypress

cypress-jest-adapter provides set of custom assertions using jest assertion style to Cypress expect command

Allow to use jest style commands to do assertion:

expect(1).toEqual(1)

besides chai assertions style of

expect(1).to.be.equal(1)

Also, can do assertions for jQuery elements return from cy.get() function directly:

expect($el).toHaveId
expect($el).toHaveClass

Example

Installation

yarn add cypress-jest-adapter

or

npm install --save cypress-jest-adapter

Add cypress-jest-adapter to cypress support/index.js file

import 'cypress-jest-adapter'

Assertions

Available assertions:

Value assertion (using jest matchers)

|method |assertions | |-----------------------|-----------------------------------| |toBe |expect(sth).toBe | |toBeCloseTo |expect(sth).toBeCloseTo | |toBeDefined |expect(sth).toBeDefined | |toBeFalsy |expect(sth).toBeFalsy | |toBeGreaterThan |expect(sth).toBeGreaterThan | |toBeGreaterThanOrEqual |expect(sth).toBeGreaterThanOrEqual | |toBeLessThan |expect(sth).toBeLessThan | |toBeLessThanOrEqual |expect(sth).toBeLessThanOrEqual | |toBeInstanceOf |expect(sth).toBeInstanceOf | |toBeNull |expect(sth).toBeNull | |toBeTruthy |expect(sth).toBeTruthy | |toBeUndefined |expect(sth).toBeUndefined | |toBeNaN |expect(sth).toBeNaN | |toContain |expect(sth).toContain | |toContainEqual |expect(sth).toContainEqual | |toEqual |expect(sth).toEqual | |toHaveLength |expect(sth).toHaveLength | |toMatch |expect(sth).toMatch | |toMatchObject |expect(sth).toMatchObject | |toHaveProperty |expect(sth).toHaveProperty | |toStrictEqual |expect(sth).toStrictEqual | |toThrow |expect(sth).toThrow |

Promise handlers

|method |assertions | |-----------------------|-----------------------------------| |resolves |expect(sth).resolves.toBe(sth) | |rejects |expect(sth).rejects.toThrow(error) |

Mock assertions (using chai, chai-sinon and jest equal assertion)

|method |assertions | |-----------------------|-----------------------------------| |toHaveBeenCalled |expect(spy).toHaveBeenCalled | |toHaveBeenCalledTimes |expect(spy).toHaveBeenCalledTimes | |toHaveBeenCalledWith |expect(spy).toHaveBeenCalledWith | |toHaveBeenNthCalledWith|expect(spy).toHaveBeenNthCalledWith| |toHaveReturned |expect(spy).toHaveReturned | |toHaveReturnedTimes |expect(spy).toHaveReturnedTimes | |toHaveReturnedWith |expect(spy).toHaveReturnedWith | |toHaveLastReturnedWith |expect(spy).toHaveLastReturnedWith | |toHaveNthReturnedWith |expect(spy).toHaveNthReturnedWith |

Assumptions

|method |assertions | |-----------------------|-------------------------------------------| |anything |expect(sth).toBe(expect.anything()) | |any |expect(sth).toBe(expect.any()) | |arrayContaining |expect(sth).toBe(expect.arrayContaining()) | |objectContaining |expect(sth).toBe(expect.objectContaining())| |stringContaining |expect(sth).toBe(expect.stringContaining())| |stringMatching |expect(sth).toBe(expect.stringMatching()) |

Not implement Jest functions

|method | |-----------------------------------| |toMatchSnapshot | |toMatchInlineSnapshot | |toThrowErrorMatchingSnapshot | |toThrowErrorMatchingInlineSnapshot | |assertions | |hasAsertions |

For detailed usages, go to jest expect documentation

Jest-Jquery assertions

|method |assertions |chai-jquery equivalent | |---------------------------|----------------------------------------------------------------------|------------------------| |toHaveAttr |expect($ele).toHaveAttr(attribute: string, value?: string) |to.have.attr | |toHaveProp |expect($ele).toHaveProp(property: string, value?: string) |to.have.prop | |toHaveCss |expect($ele).toHaveCss(css: string/object, value?: string) |to.have.css | |toHaveData |expect($ele).toHaveData(key: string, data?: string) |to.have.data | |toHaveClass |expect($ele).toHaveClass(className: string) |to.have.class | |toHaveId |expect($ele).toHaveId(id: string) |to.have.id | |toHaveHtml |expect($ele).toHaveHtml(html: string) |to.have.html | |toHaveText |expect($ele).toHaveText(text: string) |to.have.text | |toHaveValue |expect($ele).toHaveValue(value: string) |to.have.value | |toBeVisible |expect($ele).toBeVisible() |to.be.visible | |toBeHidden |expect($ele).toBeHidden() |to.be.hidden | |toBeSelected |expect($ele).toBeSelected() |to.be.selected | |toBeChecked |expect($ele).toBeChecked() |to.be.checked | |toBeEnabled |expect($ele).toBeEnabled() |to.be.enabled | |toBeDisabled |expect($ele).toBeDisabled() |to.be.disabled | |toBeEmpty |expect($ele).toBeEmpty() |to.be.empty | |toExist |expect($ele).toExist() |to.exist | |toBeMatchedBy |expect($ele).toBeMatchedBy(selector: string) |to.match | |toMatchSelector |expect($ele).toMatchSelector(selector: string) |to.match | |toContainText |expect($ele).toContainText(text: string) |to.contain | |toHaveDescendant |expect($ele).toHaveDescendant(selector: string) |to.have.descendants | |toHaveDescendantWithText |expect($ele).toHaveDescendantWithText(selector: string, text: string) | | |toHaveQuantity |expect($ele).toHaveQuantity(length: number) | | |toHaveTag |expect($ele).toHaveTag(tag: string) | | |toBeFocused |expect($ele).toBeFocused() | |

Used library:

License

MIT