mercredi 27 novembre 2019

How to set attributes using vue-test-utils on shallowMount?

I want to test methods in my Vue component, but I need to mock some attributes data for that, that I will access later on as this.$attrs.pattern etc... My current code is:

let wrapper;

beforeEach(() => {
   wrapper = shallowMount(Input);
});

afterEach(() => {
   wrapper.destroy();
});

it('should pass pattern check', () => {
   // I want to setup pattern attribute here
   expect(wrapper.vm.passPatternCheck).toBeTruthy();
});

I was expecting there to be something like wrapper.setProps(), but can't find it yet.

Aucun commentaire:

Enregistrer un commentaire