7

I am new with JEST and have received the above warning. I want to know which is the alternative since is being deprecated.

Here is the test that I am making:

it('is instantiated', () => {
expect(wrapper.isVueInstance()).toBeTruthy();

});

enter image description here

2
  • Typically the message that tells you something is deprecated also tells you what to use instead. What is the exact message you're seeing?
    – Ken White
    May 9, 2020 at 1:50
  • 1
    @KenWhite nop, It only says that. However, I have checked vue-test-utils.vuejs.org/api/wrapper/#isvisible and found the answer so I posted it. Thanks!
    – MaynorSong
    May 9, 2020 at 1:56

3 Answers 3

11

Here's how to rigorously check VueInstance

https://github.com/vuejs/vue-test-utils/blob/2d6b49780c7e1d663b877ddf5d6492ed7b510379/packages/test-utils/src/wrapper.js#L400

it('is instantiated', () => {
    expect(wrapper.vm).toBeTruthy();
});
6

I have checked https://vue-test-utils.vuejs.org/api/wrapper/#isvisible and they say:

Assert Wrapper is Vue instance.

So the final thing would be:

it('is instantiated', () => {
    expect(wrapper).toBeTruthy();
  });
0
3

The right answer should be the following:

it('is instantiated', () => {
    expect(wrapper.exists()).toBeTruthy();
});

From test/specs/wrapper/find.spec.js in vue-test-utils repository, you can see that when wrapper doesnt exists they assert Wrapper object with exists().

  it('returns empty Wrapper with error if no nodes are found', () => {
    const wrapper = mountingMethod(Component)
    const selector = 'pre'
    const error = wrapper.find(selector)
    expect(error.exists()).toEqual(false)
    expect(error.selector).toEqual(selector)
  })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.