最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular Protractor: No specs found - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question asked Jun 3, 2015 at 9:30 ArninjaArninja 7451 gold badge12 silver badges24 bronze badges 1
  • you have to run conf.js file and in that, you have to write spec section: something like this : exports.config = { seleniumAddress: 'localhost:4444/wd/hub', specs: ['test.js']} – binariedMe Commented Jun 3, 2015 at 9:32
Add a ment  | 

1 Answer 1

Reset to default 3

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");
        });
    });
});
发布评论

评论列表(0)

  1. 暂无评论