Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 黄瓜,量角器测试通过,即使它不正确_Javascript_Testing_Protractor_Cucumber - Fatal编程技术网

Javascript 黄瓜,量角器测试通过,即使它不正确

Javascript 黄瓜,量角器测试通过,即使它不正确,javascript,testing,protractor,cucumber,Javascript,Testing,Protractor,Cucumber,我正在使用Cumber(和Cumber报告)的量角器来测试我的应用程序,但我在启动它时遇到了一个问题。我检查一个字符串是否等于另一个字符串,但不等于,并且我知道它。事实上,在测试启动后,测试通过了,但返回了一个exeption 控制台返回以下内容: [15:56:41] E/launcher - expected 'Login Failed: This value is not existing' to equal 'Values are in

我正在使用Cumber(和Cumber报告)的量角器来测试我的应用程序,但我在启动它时遇到了一个问题。我检查一个字符串是否等于另一个字符串,但不等于,并且我知道它。事实上,在测试启动后,测试通过了,但返回了一个exeption

控制台返回以下内容:

[15:56:41] E/launcher - expected 'Login Failed: This value is not existing'
                          to equal 'Values are incorrect'
[15:56:41] E/launcher - AssertionError: expected 'Login Failed: This value is not existing'
                          to equal 'Values are incorrect'
My stepdefinitions.js:

Then('I see the alert "Values are incorrect" for the contents which does not match the proper data',
    function (next) {

    let failed_msg = element(by.css('.faild-message'));
    failed_msg.getText().then(function(text){
        console.log('MY ALERT MESSAGE FOR SCENARIO EIGHT IS: ',text);
        expect(text.should.be.equal("Values are incorrect"));  
        next();
    });
});
console.log的输出为:

MY ALERT MESSAGE FOR SCENARIO EIGHT IS:  Login Failed: This value is not existing
有人能帮我吗


PS:Cucumber报告没有显示有关此异常的任何信息,并告诉我每个测试都通过了。为什么?字符串不相等,console也告诉我了。如何解决这个问题?

您需要在此块中执行返回或回调(我更喜欢返回而不是回调):


因为您是在承诺范围内工作并发送回调,所以需要向上返回,以便在运行内的代码之前不会通过步骤。

您是否在Gragrator conf.js中添加了
SELENIUM\u promise\u MANAGER:false
?嗨,Kyle,感谢您的回复。我尝试了您的解决方案,但正确地说,它在控制台上失败了,但在cucumber的报告中,每一步都通过了:/也许前面的下一步()和返回expect会起作用?这似乎真的很奇怪,是相同的:/我的想法是,它将返回expect语句的失败状态,而不是提前返回回调(如果返回了)。我不知道,这是一个非常奇怪的情况。我认为这是一个配置问题,但我不知道是什么问题
Then('I see the alert "Values are incorrect" for the contents which does not match the proper data', function (next) {
    let failed_msg = element(by.css('.faild-message'));
    return failed_msg.getText().then(function(text){
        console.log('MY ALERT MESSAGE FOR SCENARIO EIGHT IS: ',text);
        expect(text.should.be.equal("Values are incorrect"));  
        return next();
    });
});