I'm writing tests with mocha that check that a changing state polled from a rest api is rendered correctly. Is it possible to change what the mocked endpoint returns in the middle of the test? I've tried overriding the mocked endpoint and using var
as the data and changing it but neither works.
With override:
it("should render correctly") {
loadPage(done, {init: function() {
testUtils.mockjax("/url", {"data": "data"})
}, onload: function() {
expect($$("#data")).to.be.visible()
testUtils.mockjax("/url", {"data": ""})
clock.tick(5000)
expect($$("#data")).not.to.be.visible() # does not work
...
done()
}
}
With variable:
it("should render correctly") {
var data = {"data": "data"}
loadPage(done, {init: function() {
testUtils.mockjax("/url", data)
}, onload: function() {
expect($$("#data")).to.be.visible()
data = {"data": ""}
clock.tick(5000)
expect($$("#data")).not.to.be.visible() # does not work
...
done()
}
}