-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cabba3a
commit 98d2ef6
Showing
5 changed files
with
30 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
.vscode-test/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,37 @@ | ||
import * as path from "path"; | ||
import * as Mocha from "mocha"; | ||
import * as glob from "glob"; | ||
import Mocha = require("mocha"); | ||
import { glob } from "glob"; | ||
|
||
export function run(): Promise<void> { | ||
// Create the mocha test | ||
export async function run(): Promise<void> { | ||
// Create the Mocha test instance | ||
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); | ||
} | ||
try { | ||
// Use glob's promise-based API to find test files | ||
const files = await glob("**/*.test.js", { cwd: testsRoot }); | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
// Add each test file to the Mocha test suite | ||
files.forEach(file => mocha.addFile(path.resolve(testsRoot, file))); | ||
|
||
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); | ||
} | ||
// Run the tests and handle results | ||
return new Promise((resolve, reject) => { | ||
mocha.run((failures: number) => { | ||
if (failures > 0) { | ||
reject(new Error(`${failures} tests failed.`)); | ||
} | ||
else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
catch (err) { | ||
console.error("Error setting up tests:", err); | ||
throw err; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters