错误:无法找到模块' jasmine-expect' [量角器]

时间:2016-05-09 16:14:19

标签: angularjs selenium-webdriver npm protractor git-bash

我正在尝试运行一个只连接到我的应用程序的量角器测试。

当我跑(git bash / terminal)时:

   protractor conf.js

我收到以下错误:"

  

错误:无法找到模块' 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'
   }
};

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

首先,尝试在不使用-g标志的情况下安装软件包:

npm install jasmine-expect

另外,将require('jasmine-expect');describe下方移动到Protractor配置文件中的onPrepare()

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

答案 1 :(得分:0)

确保将依赖项添加到package.json文件中。

library(dplyr)
df_r <- df %>% group_by(group, X) %>% mutate(maxY = max(Y)) %>% 
               group_by(group) %>% filter(Y <= min(maxY)) %>% select(group, X, Y)

> df_r
   group X Y
1     G1 a 1
2     G1 a 2
3     G1 a 3
4     G1 a 4
5     G1 a 5
6     G1 a 6
7     G1 a 7
8     G1 a 8
9     G1 b 1
10    G1 b 2
11    G1 b 3
12    G1 b 4
13    G1 b 5
14    G1 b 6
15    G1 b 7
16    G1 b 8
17    G2 c 1
18    G2 c 2
19    G2 c 3
20    G2 c 4
21    G2 d 1
22    G2 d 2
23    G2 d 3
24    G2 d 4

> df_r1 <- data.frame(group = c(rep("G1",16), rep("G2", 8)), X = c(rep("a", 8), rep("b", 8), rep("c", 4), rep("d", 4)), Y = c(rep(1:8), rep(1:8), rep(1:4), rep(1:4)))
> identical(df_r, df_r1)
[1] TRUE