Skip to content

Commit

Permalink
Create test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 6, 2016
1 parent f369c90 commit 8cfde38
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
"env": {
"browser": true,
"commonjs": true,
Expand All @@ -10,7 +11,7 @@ module.exports = {
"sourceType": "module"
},
"plugins": [
"vue"
"html"
],
"rules": {
"indent": [
Expand Down
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/node_modules
/test/specs.js
.DS_Store
.DS_Store
node_modules/
npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
39 changes: 37 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
"name": "vue-form-generator",
"version": "0.1.0",
"description": "A schema-based form generator component for Vue.js",
"homepage": "https://github.com/icebob/vue-form-generator",
"main": "dist/vue-form-generator.js",
"scripts": {
"build": "webpack --config webpack.build.config.js",
"dev": "webpack-dev-server --config webpack.dev.config.js --inline --hot --content-base dev/",
"lint": "eslint --ext=.js,.vue src",
"test": "webpack --config test/webpack.config.js"
"coverage": "set TEST_TYPE=coverage & karma start karma.config.js",
"unit": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run lint && npm run unit && npm run e2e",
"ci": "karma start test/unit/karma.conf.js --auto-watch --no-single-run --reporters=dots"
},
"keywords": [
"vue",
Expand All @@ -17,33 +22,63 @@
"schema",
"json"
],
"files": [
"dist/vue-form-generator.js",
"dist/vue-form-generator.min.js",
"src"
],
"author": "Icebob",
"license": "MIT",
"devDependencies": {
"babel-core": "6.7.7",
"babel-loader": "6.2.4",
"babel-plugin-espower": "2.1.2",
"babel-plugin-transform-runtime": "6.7.5",
"babel-preset-es2015": "6.6.0",
"babel-preset-stage-0": "6.5.0",
"babel-runtime": "5.8.38",
"chai": "3.5.0",
"css-loader": "0.23.1",
"eslint": "2.9.0",
"eslint-friendly-formatter": "2.0.4",
"eslint-loader": "1.3.0",
"eslint-plugin-html": "1.4.0",
"eslint-plugin-vue": "0.1.1",
"faker": "3.1.0",
"inject-loader": "2.0.1",
"isparta-loader": "2.0.0",
"jade": "1.11.0",
"jade-loader": "0.8.0",
"karma": "0.13.9",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1",
"karma-coverage": "0.5.5",
"karma-mocha": "0.2.2",
"karma-phantomjs-launcher": "1.0.0",
"karma-sinon-chai": "1.2.0",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "1.7.0",
"lodash": "4.11.1",
"lolex": "1.4.0",
"mocha": "2.4.5",
"mocha-generators": "1.2.0",
"mocha-loader": "0.7.1",
"moment": "2.13.0",
"node-sass": "3.6.0",
"phantomjs-prebuilt": "2.1.3",
"sass-loader": "3.2.0",
"sinon": "1.17.4",
"sinon-chai": "2.8.0",
"style-loader": "0.13.1",
"vue": "1.0.21",
"vue-hot-reload-api": "1.3.2",
"vue-html-loader": "1.2.2",
"vue-loader": "8.2.3",
"vue-style-loader": "1.0.0",
"webpack": "1.13.0",
"webpack-dev-server": "1.14.1"
"webpack-dev-server": "1.14.1",
"webpack-merge": "0.12.0"
},
"dependencies": {
"joi": "8.0.5",
Expand Down
11 changes: 11 additions & 0 deletions test/unit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// require all test files (files that ends with .spec.js)
var testsContext = require.context('./specs', true, /\.spec$/);
testsContext.keys().forEach(testsContext);

/*
// require all src files except main.js for coverage.
// you can also change this to match only the subset of files that
// you want coverage for.
var srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
srcContext.keys().forEach(srcContext)
*/
48 changes: 48 additions & 0 deletions test/unit/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var wsConfig = require('./webpack.test.config');

module.exports = function(config) {
var settings = {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

browsers: ['PhantomJS'],

reporters: ['spec', 'coverage'],

frameworks: ['mocha', 'chai'/*, 'sinon-chai'*/],

files: ['./index.js'],

exclude: [],

preprocessors: {
'./index.js': ['webpack', 'sourcemap']
},

webpack: wsConfig,

webpackMiddleware: {
noInfo: true
},

port: 9876,

colors: true,

logLevel: config.LOG_INFO,

autoWatch: false,

singleRun: true,

coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
}
}

config.set(settings);
}
18 changes: 18 additions & 0 deletions test/unit/specs/test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from "chai";

import VueFormGenerator from "src/index";

describe("VueFormGenerator", () => {

it("class properties", () => {

expect(true).to.be.true;

expect(VueFormGenerator).to.be.exist;
expect(VueFormGenerator).to.have.property("component");
expect(VueFormGenerator).to.have.property("schema");
expect(VueFormGenerator).to.have.property("validators");

});

})
68 changes: 68 additions & 0 deletions test/unit/webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
var path = require("path");
var webpack = require('webpack');

module.exports = {
devtool: '#inline-source-map',

module: {
loaders: [
{
"test": /\.js?$/,
"exclude": /node_modules/,
"loader": "babel",
"query": {
"presets": [
"es2015",
"stage-0"
],
"plugins": []
}
},
{
"test": /\.css?$/,
"loader": "style!css"
},
{
"test": /\.scss?$/,
"loader": "style!css!sass"
},
{
"test": /\.jade?$/,
"loader": "jade"
},
{
"test": /\.vue?$/,
"loader": "vue"
},
{
test: /\.(woff2?|svg)$/,
loader: 'url'
//loader: 'url?limit=10000'
},
{
test: /\.(ttf|eot)$/,
loader: 'url'
}
]
},

resolve: {
packageAlias: 'browser',
alias: {
'src': path.resolve(__dirname, '../../src')
}
},

plugins: [
],

vue: {
autoprefixer: {
browsers: ['last 2 versions']
}/*,
loaders: {
js: 'isparta'
}*/
}

};

0 comments on commit 8cfde38

Please sign in to comment.