gulp-量角器端到端测试未找到规格
gulp-protractor no specs found with e2e test
当我 运行 量角器时,我一直收到没有找到规格的错误。我尝试了一个特定的单个文件、1 个目录 e2e/*.js
和整个树 e2e/**/*.js
.
protractor.config.js
exports.config = {
specs: ['e2e/**/*.js'],
capabilities:{
browserName: 'chrome',
debug: true
},
localSeleniumStandaloneOpts:{
port:8082
}
}
gulpfile.js
'use strict';
var gulp = require('gulp');
var protractor = require("gulp-protractor").protractor;
// Setting up the test task
gulp.task('protractor', function(callback) {
gulp
.src(['e2e/**/*.js'])
.pipe(protractor({
configFile: 'protractor.conf.js',
args:['-port','8095']
}))
.on('error', function(e) {
console.log(e);
});
});
e2e/login.specs.js
'use strict';
describe('login to admin app', function(){
beforeEach(function(){
browser.get('http://localhost:3000/#!/login');
it('expect to be on the login page', function(){
expect(browser.findElement(by.className('login-page')).isPresent()).toBe(true);
});
it('login to application', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.getCurrentUrl()).toMatch('http://localhost:3000/#!/landing');
});
it('check header after login', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('*****');
passwordInput.sendKeys('*****');
submitButton.click();
expect(browser.findElement(by.id('role')));
expect(browser.findElement(by.id('username')));
var languages = brower.findElement(by.className("language"));
expect(language[0][0].getText().toEqual("NL"));
expect(language[1][0].getText().toEqual("FR"));
});
});
});
我是不是错过了一个配置?
我找到了,根据AngularJS的e2e测试站点:https://docs.angularjs.org/guide/e2e-testing一切都分成代码块。所以在 describe 函数中,你有 beforeEach、afterEach 和它。
我将 'it' 函数放在 'beforeEach'.
中
describe('login to admin app', function(){
beforeEach(function(){
browser.get('http://localhost:3000/#!/login');
});//this line was missing
it('expect to be on the login page', function(){
expect(browser.findElement(by.className('login-page')).isPresent()).toBe(true);
});
it('login to application', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.getCurrentUrl()).toMatch('http://localhost:3000/#!/landing');
});
it('check header after login', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.findElement(by.id('role')));
expect(browser.findElement(by.id('username')));
var languages = brower.findElement(by.className("language"));
expect(language[0][0].getText().toEqual("NL"));
expect(language[1][0].getText().toEqual("FR"));
});
});
当我 运行 量角器时,我一直收到没有找到规格的错误。我尝试了一个特定的单个文件、1 个目录 e2e/*.js
和整个树 e2e/**/*.js
.
protractor.config.js
exports.config = {
specs: ['e2e/**/*.js'],
capabilities:{
browserName: 'chrome',
debug: true
},
localSeleniumStandaloneOpts:{
port:8082
}
}
gulpfile.js
'use strict';
var gulp = require('gulp');
var protractor = require("gulp-protractor").protractor;
// Setting up the test task
gulp.task('protractor', function(callback) {
gulp
.src(['e2e/**/*.js'])
.pipe(protractor({
configFile: 'protractor.conf.js',
args:['-port','8095']
}))
.on('error', function(e) {
console.log(e);
});
});
e2e/login.specs.js
'use strict';
describe('login to admin app', function(){
beforeEach(function(){
browser.get('http://localhost:3000/#!/login');
it('expect to be on the login page', function(){
expect(browser.findElement(by.className('login-page')).isPresent()).toBe(true);
});
it('login to application', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.getCurrentUrl()).toMatch('http://localhost:3000/#!/landing');
});
it('check header after login', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('*****');
passwordInput.sendKeys('*****');
submitButton.click();
expect(browser.findElement(by.id('role')));
expect(browser.findElement(by.id('username')));
var languages = brower.findElement(by.className("language"));
expect(language[0][0].getText().toEqual("NL"));
expect(language[1][0].getText().toEqual("FR"));
});
});
});
我是不是错过了一个配置?
我找到了,根据AngularJS的e2e测试站点:https://docs.angularjs.org/guide/e2e-testing一切都分成代码块。所以在 describe 函数中,你有 beforeEach、afterEach 和它。 我将 'it' 函数放在 'beforeEach'.
中describe('login to admin app', function(){
beforeEach(function(){
browser.get('http://localhost:3000/#!/login');
});//this line was missing
it('expect to be on the login page', function(){
expect(browser.findElement(by.className('login-page')).isPresent()).toBe(true);
});
it('login to application', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.getCurrentUrl()).toMatch('http://localhost:3000/#!/landing');
});
it('check header after login', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.findElement(by.id('role')));
expect(browser.findElement(by.id('username')));
var languages = brower.findElement(by.className("language"));
expect(language[0][0].getText().toEqual("NL"));
expect(language[1][0].getText().toEqual("FR"));
});
});