Browse Source

Use source maps for tests

Vidar Tonaas Fauske 8 years ago
parent
commit
952fc7e0da
5 changed files with 26 additions and 9 deletions
  1. 2 2
      jupyterlab/__init__.py
  2. 3 1
      package.json
  3. 3 0
      test/karma.conf.js
  4. 2 1
      test/src/tsconfig.json
  5. 16 5
      test/webpack.conf.js

+ 2 - 2
jupyterlab/__init__.py

@@ -21,8 +21,8 @@ If you're working on the TypeScript sources of JupyterLab, try running
 
     npm run watch
 
-from the JupyterLab repo directory in another terminal window to have the 
-system incrementally watch and build JupyterLab's TypeScript for you, as you 
+from the JupyterLab repo directory in another terminal window to have the
+system incrementally watch and build JupyterLab's TypeScript for you, as you
 make changes.
 """
 

+ 3 - 1
package.json

@@ -33,6 +33,7 @@
     "@types/mocha": "^2.2.32",
     "@types/requirejs": "^2.1.28",
     "@types/sanitize-html": "^1.13.31",
+    "awesome-typescript-loader": "^2.2.4",
     "concurrently": "^2.0.0",
     "css-loader": "^0.23.1",
     "expect.js": "^0.3.1",
@@ -47,6 +48,7 @@
     "karma-ie-launcher": "^0.2.0",
     "karma-mocha": "^0.2.1",
     "karma-mocha-reporter": "^1.1.5",
+    "karma-sourcemap-loader": "^0.3.7",
     "mocha": "^2.3.4",
     "raw-loader": "^0.5.1",
     "rimraf": "^2.5.0",
@@ -62,7 +64,7 @@
     "build:all": "npm run build:src && npm run build:serverextension",
     "build:examples": "node scripts/buildexamples.js",
     "build:src": "tsc --project src && node scripts/copyfiles.js",
-    "build:test": "tsc --project test/src && webpack --config test/webpack.conf.js",
+    "build:test": "webpack --config test/webpack.conf.js",
     "build:serverextension": "cd jupyterlab && npm run build && cd ..",
     "clean": "rimraf docs && rimraf lib && rimraf test/build && rimraf test/coverage",
     "clean:all": "npm run clean && cd jupyterlab && npm run clean && cd ..",

+ 3 - 0
test/karma.conf.js

@@ -7,6 +7,9 @@ module.exports = function (config) {
       'node_modules/es6-promise/dist/es6-promise.js',
       'test/build/bundle.js'
     ],
+    preprocessors: {
+      'test/build/bundle.js': ['sourcemap']
+    },
     port: 9876,
     colors: true,
     singleRun: true,

+ 2 - 1
test/src/tsconfig.json

@@ -6,7 +6,8 @@
     "module": "commonjs",
     "moduleResolution": "node",
     "target": "ES5",
-    "outDir": "../build"
+    "outDir": "../build",
+    "sourceMap": true
   },
   "exclude": ["notebook"]
 }

+ 16 - 5
test/webpack.conf.js

@@ -1,20 +1,31 @@
 var path = require('path');
 
 module.exports = {
-  entry: './test/build/index.js',
+  entry: './test/src/index.ts',
   output: {
     path: __dirname + "/build",
     filename: "bundle.js",
-    publicPath: "./build/"
+    publicPath: "./test/build/"
   },
-  bail: true,
+  devtool: 'inline-source-map',
   module: {
     loaders: [
       { test: /\.css$/, loader: 'style-loader!css-loader' },
       { test: /\.md$/, loader: 'raw-loader'},
-      { test: /\.html$/, loader: "file?name=[name].[ext]" },
+      { test: /\.html$/, loader: 'file-loader?name=[name].[ext]' },
       { test: /\.ipynb$/, loader: 'json-loader' },
-      { test: /\.json$/, loader: 'json-loader' }
+      { test: /\.json$/, loader: 'json-loader' },
+      {
+        test: /\.ts$/,
+        loader: 'awesome-typescript-loader',
+        query: {
+          tsconfig: './test/src/tsconfig.json'
+        }
+      }
     ]
+  },
+  resolve: {
+    // Add '.ts' as resolvable extensions.
+    extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
   }
 }