mirror of https://github.com/zulip/zulip.git
Add a Node.js-based test runner
There are no functional changes; you can still use the shell script tools/test-js-with-node. It just delegates now to the new index.js to iterate through all the other .js files in the test directory and run them. This sets the stage for Istanbul to correctly compute test coverage. (imported from commit 6f521c78b7a314d010fa113f9c2c971ab999b637)
This commit is contained in:
parent
b32219c8eb
commit
69efe2a695
|
@ -1,18 +1,10 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
cd "$(dirname "$0")"/../zerver/tests/frontend/node
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
STATIC_DIR=`python -c 'import os;print os.path.realpath("../../../../static")'`
|
||||
|
||||
export NODE_PATH=$STATIC_DIR
|
||||
export NODE_PATH=static
|
||||
|
||||
# Run the index.js test runner, which runs all the other tests.
|
||||
INDEX_JS=zerver/tests/frontend/node/index.js
|
||||
NODEJS=$(which nodejs || which node)
|
||||
|
||||
# Run all the JS scripts in our test directory. The order that the scripts run in now
|
||||
# is fairly arbitrary, as they run isolated from each other, and none of them are
|
||||
# particularly slow.
|
||||
for js_file in *.js
|
||||
do
|
||||
echo $js_file
|
||||
$NODEJS $js_file
|
||||
done
|
||||
$NODEJS $INDEX_JS
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
var fs = require('fs');
|
||||
|
||||
// Run all the JS scripts in our test directory. The order that the scripts
|
||||
// run in now is fairly arbitrary, as they run isolated from each other, and
|
||||
// none of them are particularly slow.
|
||||
|
||||
var tests = fs.readdirSync(__dirname)
|
||||
.filter(function (filename) { return (/\.js$/i).test(filename); })
|
||||
.map(function (filename) { return filename.replace(/\.js$/i, ''); });
|
||||
|
||||
tests.forEach(function (filename) {
|
||||
if (filename === 'index.js') {
|
||||
return;
|
||||
}
|
||||
console.info('running tests for ' + filename);
|
||||
require('./' + filename);
|
||||
});
|
Loading…
Reference in New Issue