Skip to content

Commit

Permalink
Update karma configuration
Browse files Browse the repository at this point in the history
- Fixes a weird bug where tensors were spuriously disposed by tfjs in testing environment due to there being multiple tfjs instances present on the page from the different builds
- Improves stack traces to make debugging easier by disabling minification in karma webpack.
- Only webpack the main package, this means that the test files have to use the global ml5 object.
  • Loading branch information
meiamsome committed Jun 26, 2018
1 parent be9769a commit 3326cb2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
37 changes: 31 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,42 @@ module.exports = (config) => {
config.set({
frameworks: ['jasmine'],
files: [
'src/index.js',
'src/**/*_test.js',
],
preprocessors: {
'src/**/*_test.js': ['webpack'],
'src/index.js': ['webpack'],
},
webpack: {
// karma watches the test entry points
// (you don't need to specify the entry option)
// webpack watches dependencies

// webpack configuration
// TODO: This is duplication of the webpack.common.babel.js file, but they
// use different import syntaxes so it's not easy to just require it here.
// Maybe this could be put into a JSON file, but the include in the module
// rules is dynamic.
entry: ['babel-polyfill', './src/index.js'],
output: {
libraryTarget: 'umd',
filename: 'ml5.js',
library: 'ml5',
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
include: require('path').resolve(__dirname, 'src'),
},
],
},
// Don't minify the webpack build for better stack traces
optimization: {
minimize: false,
},
},
webpackMiddleware: {
noInfo: true,
Expand Down
2 changes: 1 addition & 1 deletion src/ImageClassifier/index_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint new-cap: 0 */

import * as ImageClassifier from './index';
const { ImageClassifier } = ml5;

const DEFAULTS = {
learningRate: 0.0001,
Expand Down

0 comments on commit 3326cb2

Please sign in to comment.