Skip to content

Commit

Permalink
- r better types
Browse files Browse the repository at this point in the history
Co-Authored-By: Matt Hughes <[email protected]>
  • Loading branch information
isidore and mch committed May 10, 2024
1 parent 4d43b81 commit 81d4743
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/Providers/Mocha/MochaNamer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";

import { Namer } from "../../Namer";
import {Runnable, Suite} from "mocha";

export interface MochaTest {
file: string;
Expand All @@ -9,24 +10,24 @@ export interface MochaTest {
}

export class MochaNamer extends Namer {
private ctx: MochaTest;
private ctx: Mocha.Runnable;

constructor(mochaTest: any, overrideBasePath?: string) {
if (!mochaTest) {
constructor(mochaTest: Mocha.Context, overrideBasePath?: string) {
if (!mochaTest || !mochaTest.test) {
throw new Error("Mocha test context was not supplied");
}

super('', '');

this.ctx = mochaTest.test;
this.basePath = overrideBasePath || path.dirname(this.ctx.file);
this.basePath = overrideBasePath || path.dirname(this.ctx.file!);
}

getFullTestName(testContext: MochaTest): string {
getFullTestName(testContext: Runnable): string {
let test = testContext;

let parentStack: MochaTest[] = [];
let currParent: MochaTest | undefined = test;
let parentStack: (Runnable | Suite)[] = [];
let currParent: Runnable | undefined | Suite = test;
while (currParent && currParent.parent) {
parentStack.push(currParent);
currParent = currParent.parent;
Expand Down

0 comments on commit 81d4743

Please sign in to comment.