Angular Protractor: No specs found

While investigating protractor I got the following issue:

When I ran the following code, it didn't find any specs... so the tests do not run

describe('My app', function() {

    console.log('Starting test suite "GUEST"');

    browser.get('')
        .then(function () {

            it('Should automatically redirect', function() {
                console.log('Start test 1: automatic redirection of index');
                expect(browser.getLocationAbsUrl()).toMatch("/test");
            });

        });

});

The redirection has been done correctly, but the output is:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.10.217:50382/wd/hub
Starting test suite "GUEST"
Started


No specs found
Finished in 0.004 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed

I think protractor runs through the file and finds the end before the .then promise callback function is executed and doesn't find any expects.

I might be doing it all wrong... but it seemed like the way to do it

Your test is wrapped in a promise that gets resolved after the phase of registering the tests. It should be:

describe('My app', function() {

    console.log('Starting test suite "GUEST"');

    it('Should automatically redirect', function() {
        browser.get('')
        .then(function () {
                console.log('Start test 1: automatic redirection of index');
                expect(browser.getLocationAbsUrl()).toMatch("/test");
        });
    });
});