Skip to content

How can i test custom hooks like this? #1229

Answered by cexbrayat
liujiapeng asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @liujiapeng

You don't need Vue Test Utils to test this: it's a simple function test.

I would write something like this (I did not test it):

test('addCount should increment count', () => {
  const service = useService();
  expect(service.count.value).toBe(0);
  service.addCoun();
  expect(service.count.value).toBe(1);
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@liujiapeng
Comment options

@whitespacecode
Comment options

@cexbrayat
Comment options

Answer selected by cexbrayat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants