R
R
Roman2016-04-04 11:00:52
Angular
Roman, 2016-04-04 11:00:52

How to connect global variables from external libraries when unit testing angular?

The problem is this: there is an application with the Yandex.maps API connected. The API is enabled by adding a link in the script tag and creates a global variable ymaps and is used like this:

ymaps.ready(init);

    function init(){
        myMap = new ymaps.Map("map", {
            center: [55.76, 37.64],
            zoom: 15,
            controls: ['zoomControl', 'fullscreenControl']
        });       
    };

Accordingly, the test cannot load it and gives the error "ReferenceError: Can't find variable: ymaps." I
use Karma + Jasmine for testing.
Please tell me how can I lock it or wrap it in a module to avoid an error?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question