Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster webpack and karma tdd #51

Merged
merged 4 commits into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
artifacts
client/build
client/build-test
node_modules
npm-debug.log
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ open http://localhost:8080
./e2e/run-tests
```

## Fast TDD

Run `./client/fast-tdd` and enjoy blazing fast specs

## Features

* AngularJS 1.5.x with ES2015 flavour
Expand Down
8 changes: 8 additions & 0 deletions client/fast-tdd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rm -rf tmp
./node_modules/webpack/bin/webpack.js --config client/webpack-test-fast.config.js

./node_modules/concurrently/src/main.js --raw \
"./node_modules/karma/bin/karma start client/karma-fast.config.js" \
"./node_modules/webpack/bin/webpack.js --config client/webpack-test-fast.config.js --watch"
64 changes: 64 additions & 0 deletions client/karma-fast.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '..',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
'client/build-test/vendor.js',
'client/build-test/specs.js'
],


// list of files to exclude
exclude: [],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'tmp/specs.js': ['sourcemap']
},


reporters: ['dots'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
80 changes: 80 additions & 0 deletions client/webpack-test-fast.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const combineLoaders = require('webpack-combine-loaders');
const path = require('path');
const webpack = require('webpack');

const CHUNK_FILENAME = '[name].js';

module.exports = {
entry: {
vendor: [
'jquery',
'lodash',
'angular',
'angular-animate',
'angular-messages',
'angular-resource',
'angular-loading-bar',
'angular-toastr',
'angular-ui-router',

'angular-mocks',
'chai',
'sinon'
],
specs: './client/src/specs.js'
},

output: {
path: path.resolve('./client/build-test'),
filename: CHUNK_FILENAME,
chunkFilename: CHUNK_FILENAME
},

plugins: [
new webpack.ProvidePlugin({
'window.$': 'jquery',
'window.jQuery': 'jquery'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
fileName: CHUNK_FILENAME
}),
new webpack.NoErrorsPlugin()
],

module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: combineLoaders([{
loader: 'ng-annotate'
}, {
loader: 'babel',
query: {
extends: path.join(__dirname, '.babelrc')
}
}])
}, {
test: /\.json$/,
loader: 'json'
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /sinon\.js$/,
loader: 'imports?define=>false,require=>false'
}, {
test: /\.scss$/,
loader: 'null'
}, {
test: /\.jpg$/,
loader: 'null'
}]
},

resolve: {
alias: { sinon: 'sinon/pkg/sinon.js' }
},

devtool: 'inline-source-map'
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@
"express": "^4.14.0",
"faker": "^3.1.0",
"jquery": "^3.1.1",
"lodash": "^4.17.1"
"lodash": "^4.17.2"
}
}