Make tests (and sourcemap) work with webpack4
This commit is contained in:
@@ -1,58 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>OL Spec Runner</title>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="mocha"></div>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.min.js"></script>
|
|
||||||
<script type="text/javascript" src="../node_modules/expect.js/index.js"></script>
|
|
||||||
<script type="text/javascript" src="../node_modules/sinon/pkg/sinon.js"></script>
|
|
||||||
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
|
|
||||||
<script type="text/javascript" src="../node_modules/proj4/dist/proj4.js"></script>
|
|
||||||
<script type="text/javascript" src="test-extensions.js"></script>
|
|
||||||
<!-- load polyfills: Always load the URL polyfill in a gated form so that
|
|
||||||
MS Edge has it -->
|
|
||||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL|always|gated"></script>
|
|
||||||
<script>
|
|
||||||
if (typeof initMochaPhantomJS === 'function') {
|
|
||||||
initMochaPhantomJS()
|
|
||||||
}
|
|
||||||
mocha.setup({
|
|
||||||
ui: 'bdd',
|
|
||||||
bail: false
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- This script is provided by the debug server (started with `make serve`) -->
|
|
||||||
<script type="text/javascript" src="loader.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
var runner = mocha.run();
|
|
||||||
if (window.console && console.log) {
|
|
||||||
// write stacks to the console for failed tests
|
|
||||||
runner.on('fail', function(test, err) {
|
|
||||||
if (test.duration > test._timeout) {
|
|
||||||
var titles = [];
|
|
||||||
for (var p = test; p; p = p.parent) {
|
|
||||||
if (p.title) {
|
|
||||||
titles.unshift(p.title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log('Test timed out:', titles.join(' > '));
|
|
||||||
}
|
|
||||||
console.error(test.err.stack);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<!--
|
|
||||||
Tests should not depend on any specific markup and should instead create
|
|
||||||
whatever elements are needed (cleaning up when done).
|
|
||||||
-->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// require all modules ending in ".test.js" from the
|
||||||
|
// current directory and all subdirectories
|
||||||
|
const testsContext = require.context('.', true, /\.test\.js$/);
|
||||||
|
|
||||||
|
testsContext.keys().forEach(testsContext);
|
||||||
+10
-5
@@ -39,26 +39,31 @@ module.exports = function(karma) {
|
|||||||
}, {
|
}, {
|
||||||
pattern: path.resolve(__dirname, './test-extensions.js')
|
pattern: path.resolve(__dirname, './test-extensions.js')
|
||||||
}, {
|
}, {
|
||||||
pattern: '**/*.test.js'
|
pattern: path.resolve(__dirname, './index_test.js'),
|
||||||
|
watched: false
|
||||||
}, {
|
}, {
|
||||||
pattern: '**/*',
|
pattern: '**/*',
|
||||||
included: false,
|
included: false,
|
||||||
watched: false
|
watched: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
exclude: [
|
||||||
|
'**/*.test.js'
|
||||||
|
],
|
||||||
proxies: {
|
proxies: {
|
||||||
'/rendering/': '/base/rendering/',
|
'/rendering/': '/base/rendering/',
|
||||||
'/spec/': '/base/spec/'
|
'/spec/': '/base/spec/'
|
||||||
},
|
},
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'**/*.js': ['webpack']
|
'**/*.js': ['webpack', 'sourcemap']
|
||||||
},
|
},
|
||||||
reporters: ['progress'],
|
reporters: ['progress'],
|
||||||
|
webpack: {
|
||||||
|
devtool: 'inline-source-map',
|
||||||
|
mode: 'development'
|
||||||
|
},
|
||||||
webpackMiddleware: {
|
webpackMiddleware: {
|
||||||
noInfo: true
|
noInfo: true
|
||||||
},
|
|
||||||
webpack: {
|
|
||||||
mode: 'development'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user