Torben
Torben

Reputation: 478

JS Tests in Visual Studio fail with Chutzpah but succeed when executed in browser

I am facing a problem with Chutzpah in Visual Studio 2017. I have some Tests for my jQuery Code, which run successfully in the Browser (Firefox, Edge & Chrome), but fail when running them in VS with Chutzpah.

First of all my setup:

My tests written in Jasmin with the extension 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"});
  });

});

When I run the tests in the browser i get

Test in Browser

enter image description here

which is totally fine. But when I run the test in VS with right click on the HTML file and "Run JS Tests". I get

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)

Suddenly the last test fails and I have no idea why.

Upvotes: 0

Views: 415

Answers (0)

Related Questions