From a8c3109b9ac5b161bd3b013274e231b76500e1e1 Mon Sep 17 00:00:00 2001 From: Raymonzut <40148684+Raymonzut@users.noreply.github.com> Date: Sun, 26 Apr 2020 16:38:57 +0200 Subject: [PATCH] Create crude test runner --- client/test_runner.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 client/test_runner.js diff --git a/client/test_runner.js b/client/test_runner.js new file mode 100644 index 0000000..57b9f42 --- /dev/null +++ b/client/test_runner.js @@ -0,0 +1,22 @@ +const { spawn } = require('child_process') +const fs = require('fs') + +const dirs = ['./test', './tests'] + +if (!dirs.some(fs.existsSync)) { + throw Error("Could not find any test directories, looked for: " + dirs) +} + +const test_dirs = dirs.filter(fs.existsSync) + +test_dirs.forEach(test_dir => { + const files = fs.readdirSync(test_dir) + + if (files.length === 0) { + throw Error("Could not find test files in " + test_dir) + } + + const childs = files.map(file => + spawn('node', [`${test_dir}/${file}`], { stdio: 'inherit' }) + ) +})