Api Testing Cheat Sheet

  



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

  1. Api Testing Cheat Sheet Printable
  2. Api Testing Cheat Sheet Pdf
  • renderconst {/* */} = render(Component) returns:
    • unmount function to unmount the component
    • container reference to the DOM node where the component is mounted
    • all the queries from DOM Testing Library, bound to the document so thereis no need to pass a node as the first argument (usually, you can use thescreen import instead)
  • API Cheat Sheet – What is an API, How it Works, and How to Choose the Right API Testing Tools. Building an API is fun, right? Karate is an open-source tool for operations like API test-automation, performance-testing, UI automation into a.
  • The one-page guide to RESTful API: usage, examples, links, snippets, and more.

Microsoft AZ-900 Cheat Sheet. The next important thing in this cheat sheet is to learn about the Microsoft AZ-900 exam. There has been a huge rise in the world of cloud computing from the past years. And, this is still increasing. With introducing courses like Microsoft AZ-900, Microsoft has made a clear pathway to start a career in cloud.

import{ render, fireEvent, screen }from'@testing-library/react'
test('loads items eventually',async()=>{
fireEvent.click(getByText('Load'))
// Wait for page to update with query text
const items =await screen.findAllByText(/Item #[0-9]: /)
})

Queries#

Difference from DOM Testing Library

Dead zedgaming potatoes. The queries returned from render in React Testing Library are the same asDOM Testing Library except they have the first argument bound to thedocument, so instead of getByText(node, 'text') you do getByText('text')

See Which query should I use?

Cheat
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'})
  • cleanup clears the DOM (use with afterEach to resetDOM between tests)

Text Match Options#

Testing

Given the following HTML:

Will find the div:

getByText('Hello World')// full string match

Api Testing Cheat Sheet Printable

getByText('llo Worl',{ exact:false})// substring match
getByText('hello world',{ exact:false})// ignore case
Api Testing Cheat Sheet
// Matching a regex:
getByText(/world/i)// substring match, ignore case
getByText(/^hello world$/i)// full string match, ignore case
getByText((content, element)=> content.startsWith('Hello'))

General

API

Sheet
axios.request(config)
axios.get(url[, config])
axios.delete(url[, config])
axios.head(url[, config])
axios.options(url[, config])
axios.post(url[, data[, config]])
axios.put(url[, data[, config]])
axios.patch(url[, data[, config]])
axios.all(iterable)
axios.spread(callback)
axios#create([config])
axios#request(config)
axios#get(url[, config])
axios#delete(url[, config])
axios#head(url[, config])
axios#options(url[, config])
axios#post(url[, data[, config]])
axios#put(url[, data[, config]])
axios#patch(url[, data[, config]])

Request Config

Response Schema

Config Defaults

Interceptors

Handling Errors

Api Testing Cheat Sheet Pdf

Cancellation