Visual Studio中的JS测试与Chutzpah失败,但在浏览器中执行时成功

时间:2017-04-11 07:42:59

标签: jquery visual-studio-2017 jasmine-jquery chutzpah jasmine2.0

我在Visual Studio 2017中遇到了Chutzpah的问题。我在浏览器(Firefox,Edge&amp; Chrome)中成功运行了jQuery代码,但在使用Chutzpah在VS中运行时失败了。< / p>

首先我的设置:

  • Jasmin版本2.5.2
  • Jasmin-jQuery版本2.1.1
  • jQuery版本3.1.1
  • Chutzpah 4.3.4
  • Visual Studio 2017版本15.1

我的测试用Jasmin编写,扩展名为Jasmin-jQuery。

var progressbarHTML = '<a id="progressbarCaption"></a>' +
       '<div id="progressContainer">' +
       '<div id="progressArea">' +
       '<div id="progressbar">' +
       '<div id="progresslabel" class="progress-label">' +
       '</div></div></div></div>';

describe("CSS Classes are loaded?", function() {
  beforeEach(function() {
    var html = '<div id="controlAddIn">' + progressbarHTML + '</div>';
    setFixtures(html);
    environment = {"Platform" : 0};
    InitializeControl();
  });

  it("Is CSS for progressbarCaption set", function() {
    expect($("#progressbarCaption")).toHaveClass("progressbarCaptionWidowsClient");
  });

  it("Is CSS for progressContainer set", function() {
    expect($("#progressContainer")).toHaveClass("progressContainerWindowsClient");
  });

  it("Is CSS for progresslabel set", function() {
    expect($("#progresslabel")).toHaveCss({'top': "1px"});
  });

});

当我在浏览器中运行测试时,我得到了

Test in Browser

enter image description here

这完全没问题。但是当我在VS中运行测试时,右键单击HTML文件并“运行JS测试”。我得到了

Test 'CSS Classes are loaded?:Is CSS for progresslabel set' failed
    Expected ({ 0: HTMLNode, length: 1 }) to have css Object({ top: '1px' }).
    buildExpectationResult@file:///C:/Temp/Progressbar/DEV%20DE%20CU00%2013682%20BL%203151/Control%20Add-Ins%20JS/ProgressBar/Progressbar/Resource/Tests/lib/jasmine-2.5.2/jasmine.js:1610:19
    expectationResultFactory@file:///C:/Temp/Progressbar/DEV%20DE%20CU00%2013682%20BL%203151/Control%20Add-Ins%20JS/ProgressBar/Progressbar/Resource/Tests/lib/jasmine-2.5.2/jasmine.js:655:40
    addExpectationResult@file:///C:/Temp/Progressbar/DEV%20DE%20CU00%2013682%20BL%203151/Control%20Add-Ins%20JS/ProgressBar/Progressbar/Resource/Tests/lib/jasmine-2.5.2/jasmine.js:342:58
    addExpectationResult@file:///C:/Temp/Progressbar/DEV%20DE%20CU00%2013682%20BL%203151/Control%20Add-Ins%20JS/ProgressBar/Progressbar/Resource/Tests/lib/jasmine-2.5.2/jasmine.js:599:41
    file:///C:/Temp/Progressbar/DEV%20DE%20CU00%2013682%20BL%203151/Control%20Add-Ins%20JS/ProgressBar/Progressbar/Resource/Tests/lib/jasmine-2.5.2/jasmine.js:1564:32
in C:\Temp\Progressbar\DEV DE CU00 13682 BL 3151\Control Add-Ins JS\ProgressBar\Progressbar\Resource\Tests\SpecRunner.html (line 0)

突然间,最后一次测试失败,我不明白为什么。

0 个答案:

没有答案