aboutsummaryrefslogtreecommitdiff
path: root/src/test/suite
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-24 00:03:37 +0200
committernea <nea@nea.moe>2023-06-24 00:03:37 +0200
commitc8967af51ea3fb5f9f1de80142ab9a6b7d0cfb2a (patch)
treee7fe1ae63f3ff681607a1ddb348aae4953bc7b00 /src/test/suite
downloadneudevtools-c8967af51ea3fb5f9f1de80142ab9a6b7d0cfb2a.tar.gz
neudevtools-c8967af51ea3fb5f9f1de80142ab9a6b7d0cfb2a.tar.bz2
neudevtools-c8967af51ea3fb5f9f1de80142ab9a6b7d0cfb2a.zip
Initial commit
Diffstat (limited to 'src/test/suite')
-rw-r--r--src/test/suite/index.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts
new file mode 100644
index 0000000..7029e38
--- /dev/null
+++ b/src/test/suite/index.ts
@@ -0,0 +1,38 @@
+import * as path from 'path';
+import * as Mocha from 'mocha';
+import * as glob from 'glob';
+
+export function run(): Promise<void> {
+ // Create the mocha test
+ const mocha = new Mocha({
+ ui: 'tdd',
+ color: true
+ });
+
+ const testsRoot = path.resolve(__dirname, '..');
+
+ return new Promise((c, e) => {
+ glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
+ if (err) {
+ return e(err);
+ }
+
+ // Add files to the test suite
+ files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+ try {
+ // Run the mocha test
+ mocha.run(failures => {
+ if (failures > 0) {
+ e(new Error(`${failures} tests failed.`));
+ } else {
+ c();
+ }
+ });
+ } catch (err) {
+ console.error(err);
+ e(err);
+ }
+ });
+ });
+}