Refactor test setup and improve prompt generation error handling

This commit is contained in:
2025-03-13 08:28:00 +00:00
parent 69475782eb
commit 7eb0d49d07
8 changed files with 107 additions and 433 deletions

33
src/test/index.ts Normal file
View File

@@ -0,0 +1,33 @@
import * as path from 'path';
import * as fs from 'fs';
import Mocha from 'mocha';
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<void>((resolve, reject) => {
try {
// Simple approach - add extension.test.js directly
// This will find our basic test file
mocha.addFile(path.resolve(testsRoot, 'test/extension.test.js'));
// Run the mocha test
mocha.run((failures: number) => {
if (failures > 0) {
reject(new Error(`${failures} tests failed.`));
} else {
resolve();
}
});
} catch (err) {
console.error(err);
reject(err);
}
});
}