Jasmine Cheat Sheet



Jasmine Cheat Sheet

  1. Protractor Jasmine Cheat Sheet
  2. Jasmine Cheat Sheet
  3. Jasmine Spy Cheat Sheet
  4. Jasmine Cheat Sheet

CSS Cheat Sheet contains the most common style snippets: CSS gradient, background, button, font-family, border, radius, box and text shadow generators, color picker and more. All these and other useful web designer tools can be found on a single page. Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular. Botanical Name Cheat Sheet Common Name Botanical Name Adam's Needle Yucca Allegheny Spurge Pachysandra procumbens Aster Aster Beardtongue Penstemon Bee Balm Monarda Bellwort Uvularia Black-Eyed Susan Rudbeckia Blanket Flower Gaillardia Blazing Star Liatris Bleeding Heart Dicentra Blue Flag Iris Iris versicolor Blue Lyme Grass Elymus Blue Star. Jasmine is my testing framework of choice when I’m writing Angular. And I was just getting used to all those spy methods with the help of Toby Ho’s cheat sheet, and then Jasmine 2 came along and changed all the method names. So here’s an updated cheat sheet for spying with Jasmine 2. Create a spy Spy on an existing method.

A short guide to all the exported functions in DOM Testing Library

Queries#

Sheet

See Which query should I use?

No Match1 Match1+ MatchAwait?
getBythrowreturnthrowNo
findBythrowreturnthrowYes
queryBynullreturnthrowNo
getAllBythrowarrayarrayNo
findAllBythrowarrayarrayYes
queryAllBy[]arrayarrayNo
  • ByLabelText find by label or aria-label text content
    • getByLabelText
    • queryByLabelText
    • getAllByLabelText
    • queryAllByLabelText
    • findByLabelText
    • findAllByLabelText
  • ByPlaceholderText find by input placeholder value
    • getByPlaceholderText
    • queryByPlaceholderText
    • getAllByPlaceholderText
    • queryAllByPlaceholderText
    • findByPlaceholderText
    • findAllByPlaceholderText
  • ByText find by element text content
    • getByText
    • queryByText
    • getAllByText
    • queryAllByText
    • findByText
    • findAllByText
  • ByDisplayValue find by form element current value
    • getByDisplayValue
    • queryByDisplayValue
    • getAllByDisplayValue
    • queryAllByDisplayValue
    • findByDisplayValue
    • findAllByDisplayValue
  • ByAltText find by img alt attribute
    • getByAltText
    • queryByAltText
    • getAllByAltText
    • queryAllByAltText
    • findByAltText
    • findAllByAltText
  • ByTitle find by title attribute or svg title tag
    • getByTitle
    • queryByTitle
    • getAllByTitle
    • queryAllByTitle
    • findByTitle
    • findAllByTitle
  • ByRole find by aria role
    • getByRole
    • queryByRole
    • getAllByRole
    • queryAllByRole
    • findByRole
    • findAllByRole
  • ByTestId find by)
  • configure change global options:configure({testIdAttribute: 'my-data-test-id'})

Text Match Options#

Given the following HTML:

Will find the div:

Protractor Jasmine Cheat Sheet

Jasmine cheat sheet
getByText(container,'Hello World')// full string match
getByText(container,'llo Worl',{ exact:false})// substring match
getByText(container,'hello world',{ exact:false})// ignore case

Jasmine Cheat Sheet

// Matching a regex:
getByText(container,/world/i)// substring match, ignore case
Jasmine
getByText(container,/^hello world$/i)// full string match, ignore case
getByText(container,/Hello W?oRlD/i)// advanced regex

Jasmine Spy Cheat Sheet

// Matching with a custom function:

Jasmine Cheat Sheet

getByText(container,(content, element)=> content.startsWith('Hello'))
Sheet

Given a button that updates the page after some time:

// Click button
const items =awaitfindByText(node,/Item #[0-9]: /)
})