Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/mocha-runner/src/mocha-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,23 @@ class MochaRunner implements TestRunner {
require(mod);
}
}
if (mocha.options.files!== undefined) {
if (!(mocha.options.files instanceof Array)) {
mocha.options.files = [mocha.options.files];
}
for (let mod of mocha.options.files) {
const abs = fs.existsSync(mod) || fs.existsSync(mod + '.js');
if (abs) {
mod = path.resolve(mod);
}
mocha.addFile(mod);
}
}
return mocha;
}
async discoverTests(argv: parser.Arguments): Promise<DiscoveryResult> {
const mocha = this.createMochaInstance()
await mocha.loadFilesAsync();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this because I wanted to load pre test file first

const tests: Test[] = [];
const testSuites: TestSuite[] = [];

Expand Down Expand Up @@ -113,6 +126,7 @@ class MochaRunner implements TestRunner {
for (const filename of testFilesToProcessList) {
mocha.addFile(filename);
}
await mocha.loadFilesAsync();
const runnerWithResults: CustomRunner = mocha.run(() => {
testRunTask.resolve();
});
Expand Down