Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubRequest inside withMock doesn't work #72

Open
bam opened this issue Jan 23, 2020 · 0 comments
Open

stubRequest inside withMock doesn't work #72

bam opened this issue Jan 23, 2020 · 0 comments

Comments

@bam
Copy link

bam commented Jan 23, 2020

Seems stubRequest doesn't work inside withMock.
If I use moxios.install()/uninstall() in beforeEach/afterEach stubRequest() works good.
If I use just withMock() without stubRequest and then

moxios.wait(... 
moxios.requests.mostRecent().respondWith(...).then(...)
...

it works good too.
But if I use it this way

describe('Test suite', function () {
  it('#1', function (done) {
    moxios.withMock(function () {
      moxios.stubRequest('/say/hello', {
        status: 200,
        responseText: 'hello'
      })

      let onFulfilled = jasmine.createSpy('spy1')
      axios.get('/say/hello').then(onFulfilled)

      moxios.wait(function () {
          expect(onFulfilled.calls.mostRecent().args[0].data).toBe('hello')
          done()
      })
    })
  })
})

it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant