Skip to content

Commit

Permalink
from ubuntu WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
bensonhpcheng committed Sep 23, 2024
1 parent c641538 commit ee82d02
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/suite/extensions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Import the Mocha test framework
import * as Mocha from 'mocha';
// Import Node.js path module to handle file paths
import * as path from 'path';
// Import the glob module to find test files
import { glob } from 'glob';
// Import the run function from your test runner
import { run } from './index';

// Define a Mocha test suite
suite('Extension Test Suite', () => {
// A test case within the suite
test('Sample Test', () => {
// Example assertion using Chai or Node's assert
const expected = -1;
const actual = [1, 2, 3].indexOf(4);
if (actual !== expected) {
throw new Error(`Expected indexOf(4) to be ${expected}, but got ${actual}`);
}
});

// You can add more tests here or import them from other files
});




30 changes: 30 additions & 0 deletions test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import { glob } from 'glob';

export async function run(): Promise<void> {
const mocha = new Mocha({
ui: 'bdd',
color: true,
});

const testsRoot = path.resolve(__dirname);

try {
const files = await glob('**/*.test.js', { cwd: testsRoot });

files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

await new Promise<void>((resolve, reject) => {
mocha.run((failures) => {
if (failures > 0) {
reject(new Error(`${failures} tests failed.`));
} else {
resolve();
}
});
});
} catch (err) {
return Promise.reject(err);
}
}

0 comments on commit ee82d02

Please sign in to comment.