0

I'm trying to write jasmine test to check is view changing time or not

it 'ticks the time', ->
  @time = parseInt($('#timer h1').text())
  setTimeout (->
    @after = parseInt($('#timer h1').text())
    expect(@time).toBeLessThan(@after)
  ), 1000

The problem is that when time of setTimeout is up the jasmine is already finished his job, no html code on page related to this test at that moment.

4

1 回答 1

0

Jasmine 已经为此类任务提供了解决方案:

it 'ticks the time', ->
  runs ->
    @time = parseInt($('#timer h1').text())
  waits(1000)
  runs ->
    @after = parseInt($('#timer h1').text())
    expect(@time).toBeGreaterThan(@after)
于 2013-07-10T22:17:13.150 回答