Skip to content

Commit 3326cb2

Browse files
committed
Update karma configuration
- 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.
1 parent be9769a commit 3326cb2

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

karma.conf.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,42 @@ module.exports = (config) => {
22
config.set({
33
frameworks: ['jasmine'],
44
files: [
5+
'src/index.js',
56
'src/**/*_test.js',
67
],
78
preprocessors: {
8-
'src/**/*_test.js': ['webpack'],
9+
'src/index.js': ['webpack'],
910
},
1011
webpack: {
11-
// karma watches the test entry points
12-
// (you don't need to specify the entry option)
13-
// webpack watches dependencies
14-
15-
// webpack configuration
12+
// TODO: This is duplication of the webpack.common.babel.js file, but they
13+
// use different import syntaxes so it's not easy to just require it here.
14+
// Maybe this could be put into a JSON file, but the include in the module
15+
// rules is dynamic.
16+
entry: ['babel-polyfill', './src/index.js'],
17+
output: {
18+
libraryTarget: 'umd',
19+
filename: 'ml5.js',
20+
library: 'ml5',
21+
},
22+
module: {
23+
rules: [
24+
{
25+
enforce: 'pre',
26+
test: /\.js$/,
27+
exclude: /node_modules/,
28+
loader: 'eslint-loader',
29+
},
30+
{
31+
test: /\.js$/,
32+
loader: 'babel-loader',
33+
include: require('path').resolve(__dirname, 'src'),
34+
},
35+
],
36+
},
37+
// Don't minify the webpack build for better stack traces
38+
optimization: {
39+
minimize: false,
40+
},
1641
},
1742
webpackMiddleware: {
1843
noInfo: true,

src/ImageClassifier/index_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint new-cap: 0 */
22

3-
import * as ImageClassifier from './index';
3+
const { ImageClassifier } = ml5;
44

55
const DEFAULTS = {
66
learningRate: 0.0001,

0 commit comments

Comments
 (0)