Vishal Sagar
Vishal Sagar

Reputation: 391

How to write unit test for vue-treeselect using vue test utils

I want to write unit test on vue-treeselect. I followed the testcases written in the repository. There they have taken wrapper.vm.forest.nodemap to find the options but when i try it is giving forest "undefined".

Does anyone have idea how to get wrapper.vm.forest in the wrapper.

Upvotes: 0

Views: 251

Answers (1)

Vishal Sagar
Vishal Sagar

Reputation: 391

I have used treeselect something like this

<treeselect
          v-model="selected"
          data-test="treeselect"
          :multiple="true"
          :options="options"
          placeholder
          value-consists-of="LEAF_PRIORITY"
          :required="true"
          :show-count="true"
          :default-expand-level="1"
        >

I gave data-test="treeselect" to find this component than in testcase used like this:

expect(wrapper.find('[data-test="tenants"]').vm.forest.selectedNodeIds).toEqual(["anything"]);

Upvotes: 0

Related Questions