gulp-protractor没有发现e2e测试的规格

时间:2021-08-21 01:21:27

When I run protractor I keep getting the error that no specs are found. I have tried a specific single file, 1 directory e2e/*.js and an entire tree e2e/**/*.js.

当我运行量角器时,我不断收到没有找到规格的错误。我尝试了一个特定的单个文件,1个目录e2e / * .js和一个完整的树e2e / ** / * .js。

protractor.config.js

protractor.config.js

exports.config = {
specs: ['e2e/**/*.js'],
capabilities:{
    browserName: 'chrome',
    debug: true
},
localSeleniumStandaloneOpts:{
    port:8082
}
}

gulpfile.js

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

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"));


        });


    });
});

Did I miss a configuration?

我错过了配置吗?

1 个解决方案

#1


0  

I found it, according to the e2e testing site of AngularJS: https://docs.angularjs.org/guide/e2e-testing everything is divided into code blocks. So within describe function you have beforeEach, afterEach and it. And I put my 'it' functions within 'beforeEach'.

我发现它,根据AngularJS的e2e测试网站:https://docs.angularjs.org/guide/e2e-testing测试一切都分为代码块。所以在describeEfunction中你有beforeEach,afterEach和它。我把''它'的功能放在'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


0  

I found it, according to the e2e testing site of AngularJS: https://docs.angularjs.org/guide/e2e-testing everything is divided into code blocks. So within describe function you have beforeEach, afterEach and it. And I put my 'it' functions within 'beforeEach'.

我发现它,根据AngularJS的e2e测试网站:https://docs.angularjs.org/guide/e2e-testing测试一切都分为代码块。所以在describeEfunction中你有beforeEach,afterEach和它。我把''它'的功能放在'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"));

    });
});