2016-05-09 2 views
2

Im пытается запустить тест транспортира, который просто подключается к моему приложению.Ошибка: не удается найти модуль «Жасмин-ожидание» [Транспортир]

Когда я бегу (мерзавец Баш/терминал):

protractor conf.js 

Я получаю следующее сообщение об ошибке: "

Error: Cannot find module 'jasmine-expect'

Увидев это, я пошел вперед и установил модуль:

npm install -g jasmine-expect 

Но я все еще получаю тот же отказ.

Вот мой тест:

describe('DragAndDrop Test', function() { 
require('protractor'); 
require('jasmine-expect'); 


beforeAll(function() { 
    context = new Context(); 
    context.get(); 
    browser.waitForAngular(); 
    browser.driver.manage().window().maximize(); 
}); 

it('should drag and drop Application Experience tile', function() { 

    //target is where we are dragging the box to. Box is the Box 
    var target = { x: 300, y: 50 }; 
    var box = element(by.cssContainingText('h3', 'Application Experience')); 

    //scope is going to hold the scope variables that tell us where the box is located 
    //get the standardItems Scope 

    box.evaluate('dashboards').then(function(scope) { 
     //make sure the box we are using is initially set in column 0 and Row 0 
     expect(scope['1'].widgets[0].col).toEqual(0); 
     expect(scope['1'].widgets[0].row).toEqual(0); 
    }); 

    //drag and drop the box somewhere else. 
    browser.actions().dragAndDrop(box, target).perform(); 
    browser.waitForAngular(); 
    browser.driver.sleep(5000); 

    //get the updated scope 
    box.evaluate('dashboards').then(function(scope) { 
     //test to see that the box was actually moved to column 1 and row 0 
     expect(scope['1'].widgets[0].col).toEqual(1); 
     expect(scope['1'].widgets[0].row).toEqual(0); 
    }); 
}); 

}); 

var Context = function() { 
this.ignoreSynchronization = true; 
    //load the website 
    this.get = function() { 
     browser.get('http://127.0.0.1:62734/index.html#/dashboard'); 
    }; 
}; 

Вот мои conf.js:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['gridster-Test.js'], 
    capabilities: { 
    browserName: 'firefox' 
    } 
}; 

Любые предложения?

ответ

1

Прежде всего, попробуйте установить пакет без использования -g флаг:

npm install jasmine-expect 

Кроме того, переместить require('jasmine-expect'); из-под describe в onPrepare() в файле конфигурации транспортир:

onPrepare: function() { 
    require("jasmine-expect"); 
}, 
+0

попытался установить без флага -g в дополнение к предложенному onPrepare(). Такое же сообщение об ошибке. Он не может найти жасмин-ожидание. Он успешно установлен, поэтому я не знаю, что происходит. –

0

Убедитесь, что зависимость добавлена ​​в файл package.json.

npm install jasmine-expect --save-dev 
Смежные вопросы