vendredi 5 février 2016

Jasmine test fails with error from a different suite

Experiencing some peculiar behaviour from karma-jasmine testing an angular app.

Have a test in one suite that reports failure but message comes from a separate test in another test suite file.

Test result:

factory: page should uncheck all items FAILED
  Expected undefined to contain '<div class="ui-select-container ui-select-bootstrap dropdown ng-valid" ng-class="{open: $select.open}" ng-model="test.slctbx.selected" theme="bootstrap" ng-disabled="disabled"></div>'

That test is actually:

describe 'factory: page', () ->

...

  it 'should check all items', () ->
    Page.checkAll null

    expect(Page.actions).toEqual {checkAll: false}

The error actually comes from:

describe 'directive: select', () ->

  ...

  it 'should replace select box', () ->
    replacementMarkup = '<div class="ui-select-container ui-select-bootstrap dropdown ng-valid" ng-class="{open: $select.open}" ng-model="test.slctbx.selected" theme="bootstrap" ng-disabled="disabled"></div>'

    setTimeout () ->
      expect($('select').length).toEqual 0
      expect($('form').html()).toContain replacementMarkup
      return
      , 0

If I remove the factory: page suite this behaviour simply exists but another test suite.

The timeout is smelly but this is only because that directive has a timeout within it that waits an arbitrary amount of time so the element it is about to replace has been populated... (which is a bit smelly itself!)

Aucun commentaire:

Enregistrer un commentaire