Refactor test setup and improve prompt generation error handling
This commit is contained in:
33
src/test/index.ts
Normal file
33
src/test/index.ts
Normal 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user