jeudi 8 juin 2017

How to nest Vue.nextTick when testing?

I'm trying to test what happens in my app on two consecutive ticks. This is what I have so far (the tests fail in the karma devtools, but fail in the command line):

import { mount } from 'avoriaz';
import MyComponent from './MyComponent';

describe('testing', function() {
  it('should do something', (done) => {
    const wrapper = mount(MyComponent, { store });
    wrapper.vm.changeData();
    Vue.nextTick(() => {
      expect(wrapper.vm.something).to.eql(somethingElse);
      wrapper.vm.changeData();
      Vue.nextTick(() => {
        expect(wrapper.vm.something2).to.eql(somethingElse2);
        done();
      });
      done();
    });
  });
});

I also tried using then() and catch(), but karma still thinks my failing tests are passing.

Should I only have one done() call? I'm not really sure what this callback is doing.

Aucun commentaire:

Enregistrer un commentaire