Use test/index.js as entry point for tests
authorFrank Bessou <frank.bessou@logilab.fr>
Fri, 30 Jun 2017 14:21:36 +0200
changeset 238 dec96013fe33
parent 237 dd1cf7e02866
child 239 d651819fbe6a
Use test/index.js as entry point for tests We don't want karma to build a bundle for each test file. To build a single bundle while having separate test files, we import all of them in the index.js file.
karma.conf.js
test/index.js
--- a/karma.conf.js	Thu Jun 29 12:16:33 2017 +0200
+++ b/karma.conf.js	Fri Jun 30 14:21:36 2017 +0200
@@ -16,8 +16,7 @@
         // list of files / patterns to load in the browser
         files: [
             'node_modules/babel-polyfill/dist/polyfill.js',
-            path.join(paths.test, '*.js'),
-            path.join(paths.source, '**/*.spec.js'),
+            path.join(paths.test, 'index.js'),
         ],
 
         // list of files to exclude
--- a/test/index.js	Thu Jun 29 12:16:33 2017 +0200
+++ b/test/index.js	Fri Jun 30 14:21:36 2017 +0200
@@ -30,6 +30,9 @@
 
 chai.use(chaiAsPromised);
 
+const testsContext = require.context("../src", true, /.spec.js$/);
+testsContext.keys().forEach(testsContext);
+
 const userEditionSchema = {
     "$ref": "#/definitions/CWUser",
     "definitions": {