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