Encapsulate component test boilerplate

Description

Currently there is a lot of boilerplate to setting up Vue component tests...

  • Name of the test matches name of the component.
  • Mounting beforeEach.
  • Cleaning up afterEach.
  • createLocalVue when using vue-test-utils.

Proposal

Instead of repeating ourselves, let's use functions!

(This is just a draft. Let's talk about it in this issue. Props to @winh!)

import { componentTest } from '@gitlab/specs'

componentTest('~/vue_shared/components/notes/timeline_entry.vue', { factory } => { 
  it('works', () => {
    const wrapper = factory({ 
      propsData: { foo: 7 },
    });

    expect(wrapper.props('foo')).toEqual(7);
  });
})
Edited Nov 29, 2018 by Paul Slaughter
Assignee Loading
Time tracking Loading