0
我已经设置了一个类似下面的gruntfile。目标是使用量角器为我的angularjs项目执行e2e测试。当使用mochaProtractor运行这个时,Chrome会按预期启动,但lint告诉我,我错过了expect语句的依赖关系。这应该引用断言库chai。如何包含chai的依赖关系以使其正常工作?用mochaProtractor指定依赖关系运行grunt?柴断言库?
感谢
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
scripts: {
files: ['public/specs/e2e/*.js'],
tasks: ['mochaProtractor','jshint'],
options: {
spawn: false,
},
},
},
jshint: {
all: [
'Gruntfile.js',
'public/app/js/*.js'
],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
node: true
}
},
mochaProtractor: {
options: {
browsers: ['Chrome']
},
files: ['public/specs/e2e/*.js'],
baseUrl: 'http://localhost:3000/'
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-protractor');
下面是我想对测试规范。注意:我在顶部添加了require语句以尝试使其运行。有什么想法吗?
var chai = require('chai');
var expect = chai.expect;
describe("Given a task entry screen", function() {
ptor = protractor.getInstance();
beforeEach(function() {
ptor.get('#/');
button = ptor.findElement(protractor.By.className('btn-say-hello'));
button.click();
});
it('says hello', function() {
message = ptor.findElement(protractor.By.className('message'));
expect(message.getText()).toEqual('Hello!');
});
});