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

moxios.requests.mostRecent() returns undefined #2

Closed
main-kun opened this issue Jun 9, 2016 · 5 comments
Closed

moxios.requests.mostRecent() returns undefined #2

main-kun opened this issue Jun 9, 2016 · 5 comments

Comments

@main-kun
Copy link

main-kun commented Jun 9, 2016

I use karma, jasmine and phantomJS with babel-polyfill. mostRecent always returns undefined even if I call axios in the test directly.

For example:

axios = require 'axios'
moxios = require 'moxios'

describe 'Test moxios', () ->
  beforeEach () ->
    moxios.install()

  afterEach () ->
    moxios.uninstall()

  it 'mostRecent should return a request', () ->
    axios('http://example.com').then (result) -> console.log result
    moxios.wait () ->
      console.log moxios.requests.mostRecent()
      # undefined
@maxx-coffee
Copy link
Contributor

This seems to be an issue when webpack builds the source. If you run the test importing moxios from './dist/moxios' 7 test will fail.

For now I just copied the index.js file and import it in to my test helper. I may can give a helping hand to looking in to what could cause this.

@main-kun
Copy link
Author

Hey @joshualcoffee, thank you for your help. Indeed, if i put moxios outside of node_modules and require the index file, it starts working. Though I had to add babel to my coffeescript project, would be great if i didn't have to do it.

@main-kun
Copy link
Author

Also I just realised this was mentioned in #1. So it works if i pass axios to 'moxios.install()`

@ghasemikasra39
Copy link

I am facing the same issue, any solution?

@subrato-pattanaik
Copy link

Same issue

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

4 participants