@mocktomata/plugin-axios
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

@mocktomata/plugin-axios

@mocktomata/plugin-axios is a mocktomata plugin for axios.

In basic use cases, mocktomata works with axios and do not need this plugin.

This plugin is needed only if you use additional features in axios such as interceptors.

Install

npm install -D @mocktomata/plugin-axios
yarn add -D @mocktomata/plugin-axios
pnpm add -D @mocktomata/plugin-axios

Setup

// mocktomata.json
{
	"plugins": ["@mocktomata/plugin-axios"]
}

Usage

This plugin will ignore the calls under interceptors. They will not be saved and simulated.

import axios from 'axios'

axios.interceptors.request.use(v => v) // ignored
axios.interceptors.response.use(v => v, e => e) // ignored

Note that you should not use any "speced" code inside these calls. Since the callbacks are ignored, any action triggered within will not be triggered during simulation. If there are actions triggered within, the simulation will time out as mocktomata will be waiting for those actions.

Readme

Keywords

none

Package Sidebar

Install

npm i @mocktomata/plugin-axios

Weekly Downloads

136

Version

2.0.3

License

MIT

Unpacked Size

17.6 kB

Total Files

23

Last publish

Collaborators

  • unional