Consider following service:
var cachedFoo = null;
export default Service.extend({
fetchFoo(count) {
if(!cachedFoo) {
fetch(`./api/?results=${count}`).then(function(response) {
cachedFoo = response;
});
}
}
getFoo() {
return cachedFoo;
}
});
This service will probably work as expected in the scope of running Ember code.
But if there are two tests calling this service with different value for count when calling fetchFoo, then calls to getFoo will always return the response of the first test.
Consider following service:
This service will probably work as expected in the scope of running Ember code.
But if there are two tests calling this service with different value for
countwhen callingfetchFoo, then calls togetFoowill always return the response of the first test.