Skip to content

Cloudo/cy-auto-stub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cy-auto-stub

Record and replay network requests for Cypress

This repo is based on cypress-auto-stub-example with a few differences:

  • you can specify folder and subfolder for fixture directory in describe block name, for example describe('@userform/main', ...) means that requests will be saved under fixtures/userform/main directory. Why? Because I found it easier to keep pathes for fixtures/snapshots/screenshots independent of test file path. Moreover, it allows you to create single file with all your tests imported for getting better performance. Check out this issue for more details
  • specified directory will be created with file index.json and <request>.json. You can specify url2filename function to deal with your own mapping. Why each request is in separate file? There is a limitation of 80kb max for request payload, but file fixtures solve this problem
  • each recorded request has associated fixture name. Check out url2alias function. It allows you to wait('@fixture_name') for requests.

install

yarn add -D Cloudo/cy-auto-stub

in cypress/support/index.js

import autoStub from 'cy-auto-stub'

// checkout src/defaults.js for default implementation
const options = {
  // getFixtureDir,
  // getFixturePath,
  // url2filename,
  // url2alias
}

autoStub.init(options)

todo

  • shared mocks (automatically looking up parent directory)
  • modifying responses
  • typescript support
  • compilation to es5
  • examples
  • tests

About

record/replay network requests for Cypress

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published