Thomas E
Thomas E

Reputation: 521

gulp-protractor no specs found with e2e test

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.

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


        });


    });
});

Did I miss a configuration?

Upvotes: 0

Views: 76

Answers (1)

Thomas E
Thomas E

Reputation: 521

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'.

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

    });
});

Upvotes: 0

Related Questions