Skip to content

Commit

Permalink
feat(test): add ava settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakkulkarni committed May 18, 2020
1 parent 3d61049 commit 6f4d1ac
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions template/test/helpers/ava.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const hooks = require('require-extension-hooks');

if (process.env.TEST === 'unit') {
require('jsdom-global')();
require('browser-env');
const Vue = require('vue');
Vue.config.productionTip = false;
// https://github.com/nuxt/create-nuxt-app/issues/180#issuecomment-463069941
window.Date = global.Date = Date;
// https://github.com/video-dev/hls.js/issues/2231#issuecomment-486102552
window.Number = Number;
}

if (process.env.TEST === 'e2e') {
const Vue = require('vue');
Vue.config.productionTip = false;
}

// Setup vue files to be processed by `require-extension-hooks-vue`
hooks('vue')
.plugin('vue')
.push();
// Setup vue and js files to be processed by `require-extension-hooks-babel`
hooks(['vue', 'js'])
.exclude(({ filename }) => filename.match(/\/node_modules\//))
.plugin('babel')
.push();
Empty file added template/test/snapshot/.gitkeep
Empty file.
20 changes: 20 additions & 0 deletions template/test/spec/package.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { mount, createLocalVue } from '@vue/test-utils';
import test from 'ava';
import Package from '@/src/Package.vue';

let wrapper;
const localVue = createLocalVue();

test.beforeEach(() => {
wrapper = mount(Package, {
localVue,
});
});

test('is a Vue instance', (t) => {
t.is(wrapper.isVueInstance(), true);
});

test('renders correct snapshot', (t) => {
t.snapshot(wrapper.vm.$el.outerHTML);
});

0 comments on commit 6f4d1ac

Please sign in to comment.