Error: Cannot find module 'jasmine-expect' [Protractor]
Error: Cannot find module 'jasmine-expect' [Protractor]
我正在尝试 运行 一个简单连接到我的应用程序的量角器测试。
当我运行 (git bash/terminal):
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'
}
};
有什么建议吗?
首先,尝试在不使用 -g
标志的情况下安装软件包:
npm install jasmine-expect
此外,将 require('jasmine-expect');
从 describe
下移动到 Protractor 配置文件中的 onPrepare()
中:
onPrepare: function () {
require("jasmine-expect");
},
确保将依赖项添加到您的 package.json 文件中。
npm install jasmine-expect --save-dev
我正在尝试 运行 一个简单连接到我的应用程序的量角器测试。
当我运行 (git bash/terminal):
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'
}
};
有什么建议吗?
首先,尝试在不使用 -g
标志的情况下安装软件包:
npm install jasmine-expect
此外,将 require('jasmine-expect');
从 describe
下移动到 Protractor 配置文件中的 onPrepare()
中:
onPrepare: function () {
require("jasmine-expect");
},
确保将依赖项添加到您的 package.json 文件中。
npm install jasmine-expect --save-dev