Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

moxios

> 编程语言
Open source

Mock axios requests for testing

1.4K stars0 likes2 views
WebsiteGitHub

About

Mock axios requests for testing

moxios

Mock axios requests for testing

Installing

$ npm install moxios --save-dev

Example

…

Mocking a axios.create() instance

describe('some-thing', () => {
  let axiosInstance;
  beforeEach(() => {
    axiosInstance = axios.create();
    moxios.install(axiosInstance);
  })
  afterEach(() => {
    moxios.uninstall(axiosInstance)
  })
  it('should axios a thing', (done) => {
    moxios.stubRequest('http://www.somesite.com/awesome-url', {
      status: 200,
      responseText: '…'
    })
    axiosInstance.get('http://www.somesite.com/awesome-url')
      .then(res => assert(res.status === 200))
      .finally(done)
  })
})

Thanks

moxios is heavily inspired by jasmine-ajax

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言