角度量角器:没有找到规格

时间:2015-06-03 09:30:00

标签: javascript angularjs automated-tests protractor

在调查量角器时,我遇到了以下问题:

当我运行以下代码时,它没有找到任何规格...所以测试不运行

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

        });

});

重定向已正确完成,但输出为:

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

我认为量角器会遍历文件并在 .then 承诺回调函数执行之前找到结束,并且找不到任何 expect

我可能做错了......但这似乎就是这样做的方式

1 个答案:

答案 0 :(得分:3)

您的测试包含在注册测试阶段后得到解决的承诺中。它应该是:

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