mardi 5 novembre 2019

Jest snapshot not creating snapshot in Vue.js Nuxt

I'm trying to use snapshot with my newly installed nuxt app. But the snapshot it creates doesn't look right. It says it passes the test, but as the below shows it isn't the component and when I change the component it doesn't flag it either.

My Component:

<template>
  <div>
    <footer class="container">
      <small></small>
    </footer>
  </div>
</template>

<script>
export default {
  data () {
    return {
      notice: 'text here'
    }
  }
}
</script>

My test is:

import { shallowMount, createLocalVue } from '@vue/test-utils'
import Component from '@/components/home/Component.vue'
import BootstrapVue from 'bootstrap-vue'

const localVue = createLocalVue();
localVue.use(BootstrapVue);

const factory = () => {
  return shallowMount(Component, {
    localVue
  });
};

describe('Component', () => {
  test('renders correctly', () => {
    const wrapper = factory();
    expect(wrapper).toMatchSnapshot()
  })
})

The snapshot it seems to create is this:

exports[`Component renders correctly 1`] = `
VueWrapper {
  "_emitted": Object {},
  "_emittedByOrder": Array [],
  "isFunctionalComponent": undefined,
}
`;

I'm unsure why?

Aucun commentaire:

Enregistrer un commentaire