Skip to content

Nuxt testing @nuxt/test-utils or @vue/test-utils ? #9101

Discussion options

You must be logged in to vote

@vue/test-utils is still useful for when you want to test a component separately from the app.

So for example, in my app I have a ProductBanners.vue which I test standalone.

import test from 'ava';
import { mount, createLocalVue } from '@vue/test-utils';
import { Product } from '@/assets/js/Product.js';
import ProductBanners from '@/components/product/ProductBanners.vue';

test.before('setup local Vue for these tests', (t) => {
  const localVue = createLocalVue();
  t.context.localVue = localVue;
});

test('ProductBanners - Shows nothing if not special', (t) => {
  // arrange
  const product = new Product({
    name: 'Test Product',
    price: '3.00'
  });
  const { localVue } = t.context;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@carlossolmedo
Comment options

Answer selected by carlossolmedo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants