"Q js undefined". trying to resolve a promise from aurelia-breeze in test method (karma + jasmine)

I keep getting an error while trying to resolve the aurelia-breeze promise in the aurelia application testing method ( typescript + breeze ).

The testing environment used is karma+jasmine .

Package Version aurelia-breeze 1.0.0

Aurelia breeze uses es prom instead of Q.js , but the testing method looks for Q.js to solve the promise from the wind.

I tried to add the Q library to the window object from the spec file. But breeze.debug.js trying to access Q js from the window object before it is installed in the spec file.

this did not solve the problem.

Please help me solve this problem.

+5
source share
1 answer

Something like this should work:

 import {configure as configureAureliaBreeze} from 'aurelia-breeze/index'; import {Container} from 'aurelia-dependency-injection'; const container = new Container(); configureAureliaBreeze({ container, globalResources: () => {} }); // ... tests ... 

The breeze depends on Q for promises and jQuery for ajax. Aurelia-breeze supports both of these dependencies with the ES6 promises and the aurelia http client, respectively. The above code effectively mimics what happens when you call .plugin('aurelia-breeze') when you run the aurelia application.

https://github.com/jdanyow/aurelia-breeze/blob/master/src/index.js#L15-L16

+5
source

Source: https://habr.com/ru/post/1243675/


All Articles