Skip to content

Commit

Permalink
Tests scaffolding added
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakkulkarni committed Apr 19, 2019
1 parent 346a97c commit e7020d0
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"per-file": true,
"lines": 25,
"statements": 25,
"functions": 10,
"branches": 35,
"check-coverage": true,
"include": ["src/**/*.vue", "src/**/*.js"],
"exclude": ["node_modules"],
"extension": [".js", ".vue"],
"reporter": [
"lcov",
"text"
],
"cache": true,
"all": true
}
5 changes: 5 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
require: ['./test/helpers/register.js', './test/helpers/setup.js'],
sources: ['**/*.{js,vue}'],
snapshotDir: './test/snapshot',
};
4 changes: 4 additions & 0 deletions test/helpers/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require('@babel/register')({
// These patterns are relative to the project directory (where the `package.json` file lives):
ignore: ['node_modules/*', 'test/*'],
});
25 changes: 25 additions & 0 deletions test/helpers/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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;
}

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();
24 changes: 24 additions & 0 deletions test/spec/v-clappr.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { mount, createLocalVue } from '@vue/test-utils';
import test from 'ava';
import VClappr from '@/VClappr.vue';

let wrapper;
const localVue = createLocalVue();

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

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

test('is the form buttons are clickable', t => {
t.is(wrapper.vm.$data.formSubmit, false);
});

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

0 comments on commit e7020d0

Please sign in to comment.