简体   繁体   中英

How do I get ember-qunit to use my ApplicationAdapter instead of DS.FixtureAdapter

I'm trying to use http-mock as suggested by the ember-cli documentation instead of fixtures. I generated a mock and can verify (using curl) that my ember app serves it.

However, in testing, the adapter is set to DS.FixtureAdapter and I think this is the source of the problem. If I could do something like the following:

container.register('adapter:application', ApplicationAdapter)

I think it moduleForModel() would find my adapter, where I would import ApplicationAdapter from the adapter I want to use:

import ApplicationAdapter from 'myapp/adapters/application'

But I don't know where I can put this code. I tried hooking into the delegate callback, but it wasn't getting called by moduleForModel() .

Ideas about how this is supposed to be done?

I was having the exact same problem, and thanks to the comments here I figured it out. :) Add the adapter to the needs property in the test:

moduleForModel('post', 'Post', {
  needs: ['adapter:application', ... ]
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM