gpt4 book ai didi

javascript - Angular Protractor : No specs found

转载 作者:行者123 更新时间:2023-11-30 12:22:19 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com