Skip to content

zendesk/laika

Repository files navigation

Laika logo

Try Laika on CodeSandbox

Test, mock, intercept and modify Apollo Client's operations — in both browser and unit tests!

Read the Medium article about Laika: Mock GraphQL Subscriptions with Laika — the only Apollo Client mocking tool you’ll need

Example recording output

Features

  • mock responses in either unit tests or browser tests (think Puppeteer or Cypress)
    • simulate error state
    • simulate loading state
    • simulate subscriptions (pushing data to the client at any given point)
  • it can work in production code without affecting the size of the bundle (laika is lazily loaded)
  • captures the variables that were called for a given operation for assertions
  • log all the data passing through from the network (or whatever Links are after this one)
  • record your user story
  • generate fixtures and working mock code for use in your tests
  • modify backend responses before they reach your components (e.g. to fuzz-test unexpected behavior)

Usage

Alternatives

  • MockedProvider - the official Apollo mocking tool designed for unit tests; offers no subscription mocking or recording functionality

Contribution

Thanks for your interest in our tool! Community involvement helps make our design system fresh and tasty for everyone.

Got issues with what you find here? Please feel free to create an issue.

If you'd like to take a crack at making some changes, please follow our contributing documentation for details needed to submit a PR.

Community behavior is benevolently ruled by a code of conduct. Please participate accordingly.

License

Copyright 2021 Zendesk

Licensed under the Apache License, Version 2.0