diff options
author | Kirill Dubovitskiy <kirill2003de@gmail.com> | 2023-08-07 14:54:37 -0700 |
---|---|---|
committer | Kirill Dubovitskiy <kirill2003de@gmail.com> | 2023-08-07 15:25:11 -0700 |
commit | c12be8daf60cd3d5554e9f5465aa5e8a5187d288 (patch) | |
tree | 9e92dc4a10004ec13cb2bfb45be8828bd2fb4dc6 /extension/src/test-runner/mochaRunner.ts | |
parent | 0fc56305d762181519569098a99faa255f9cd24f (diff) | |
download | sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.gz sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.bz2 sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.zip |
Refactor test scripts and update build configurations
- Added a new esbuild for:
- bundling test runners (run tests on vscode + mocha runner)
- bundling all tests in the project
- Some opinionated renamings / moving test related things around
- Changed output directory in tsconfig to avoid overriding the entire out directory - bundles tests also go there
Some poking around trying to deprecate jest as it is not used and mocha is more often used for vscode extension testing.
Though I assume jest was added to test GUI within extension.
This work was started because there are compilation issues with the current setup and neither of the tests are actually working so figured getting one to a working spot is a good start
Diffstat (limited to 'extension/src/test-runner/mochaRunner.ts')
-rw-r--r-- | extension/src/test-runner/mochaRunner.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/extension/src/test-runner/mochaRunner.ts b/extension/src/test-runner/mochaRunner.ts new file mode 100644 index 00000000..b964fe5f --- /dev/null +++ b/extension/src/test-runner/mochaRunner.ts @@ -0,0 +1,35 @@ +import * as path from "path"; +import Mocha from "mocha"; +import * as glob from "glob"; + +export function run() { + // Create the mocha test + const mocha = new Mocha({ + ui: "tdd", + color: true, + }); + + // See esbuild.test.mjs for more details + // Assumes this file is in out/test-runner/mochaRunner.js + const compiledTestSuitesDirectory = path.resolve(__dirname, "../test-suites"); + + glob.sync("**/**.test.js", { cwd: compiledTestSuitesDirectory }).forEach((file) => { + mocha.addFile(path.resolve(compiledTestSuitesDirectory, file)); + }); + + return new Promise<void>((c, e) => { + 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); + } + }); +} |