Skip to content

Commit

Permalink
Bootstrap Mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Apr 17, 2017
1 parent 58ac553 commit 7d1aa27
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
"grunt-contrib-uglify": "0.3.0",
"grunt-contrib-watch": "0.3.1",
"grunt-contrib-yuidoc": "^0.5.2",
"mocha": "^3.2.0",
"nodemon": "^1.11.0",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
},
"scripts": {
"build": "webpack",
"bump": "./node_modules/grunt-cli/bin/grunt bump",
"test": "./node_modules/grunt-cli/bin/grunt qunit",
"test": "mocha ./node_modules/babel-core/register.js test/index.js",
"test:watch": "nodemon --exec \"npm test\" --watch src --watch test",
"lint": "./node_modules/grunt-cli/bin/grunt jshint",
"start": "webpack-dev-server"
"start": "webpack-dev-server --config webpack.test.config.js"
},
"license": "MIT",
"dependencies": {
Expand Down
16 changes: 16 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Rekapi</title>
<link rel="stylesheet" href="/node_modules/mocha/mocha.css">
<script src="/node_modules/mocha/mocha.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>mocha.setup('bdd');</script>
<script src="/assets/index.js"></script>
<script>mocha.run();</script>
</body>
</html>
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* global describe:true, it:true, before:true, beforeEach:true, afterEach:true */
import assert from 'assert';

describe('Rekapi', () => {
it('works', () => {
assert(true);
});
});
5 changes: 1 addition & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,5 @@ module.exports = {
new Webpack.DefinePlugin({
REKAPI_DEBUG: true
})
],
devServer: {
port: 9010
}
]
};
42 changes: 42 additions & 0 deletions webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const path = require('path');
const Webpack = require('webpack');

const modulePaths = [
'scripts',
path.join(__dirname, 'node_modules')
];

module.exports = {
entry: './test/index.js',
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/assets/',
filename: 'index.js',
library: 'index',
libraryTarget: 'umd',
umdNamedDefine: true
},
devtool: 'source-map',
resolveLoader: {
// http://webpack.github.io/docs/troubleshooting.html#npm-linked-modules-doesn-t-find-their-dependencies
fallback: modulePaths
},
module: {
loaders: [
{
test: /\.js$/,
exclude: 'node_modules',
loader: 'babel-loader'
}
]
},
resolve: {
modulesDirectories: modulePaths,

// http://webpack.github.io/docs/troubleshooting.html#npm-linked-modules-doesn-t-find-their-dependencies
fallback: modulePaths
},
devServer: {
port: 9010
}
};

0 comments on commit 7d1aa27

Please sign in to comment.