javascript - Angular Protractor : No specs found

标签 javascript angularjs automated-tests protractor

在调查 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

我认为 Protractor 会遍历文件并在执行 .then Promise 回调函数之前找到结尾,并且没有找到任何 expect

我可能做错了......但这似乎是正确的方法

最佳答案

您的测试包含在一个 promise 中,该 promise 在注册测试阶段后得到解决。应该是:

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

关于javascript - Angular Protractor : No specs found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30616093/

相关文章:

php - 如何在不重定向到另一个页面的情况下验证用户的用户名和密码?

javascript - 更改日期调用一次功能

javascript - 如何在多个元素上使用相同的 ng-model

javascript - 使用 ng Repeat (Angular js) 在表中放置以逗号分隔的文本字段值

javascript - 直接在 URL 中过滤 API 响应

javascript - $.getScript 在点击函数中不起作用

testing - 在所有测试用例中使用相同的代码

sql-server - 如何让 MSSQL 服务容器在 Azure DevOps 管道中工作?

javascript - 我如何使用 TestCafe 访问应用程序操作?

javascript - 在 JS、JQ 或 Angular 中打印远程页面