Skip to content

Commit

Permalink
fix(utils): use test case filename when specified (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-xiao1 committed Jan 14, 2023
1 parent 539cf9f commit 37bfd14
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/utils/src/rules-tester.ts
Expand Up @@ -69,18 +69,17 @@ export class RuleTester extends TSESLint.RuleTester {
if (typeof test !== 'string' && isValidParser(test.parser)) {
throw Error(errorMessage);
}
return {
...(typeof test === 'string' ? { code: test } : test),
filename: this.filename,
};
return typeof test === 'string'
? { code: test, filename: this.filename }
: { ...test, filename: test.filename ?? this.filename };
}),
invalid: invalid.map((test) => {
if (isValidParser(test.parser)) {
throw Error(errorMessage);
}
return {
...test,
filename: this.filename,
filename: test.filename ?? this.filename,
};
}),
};
Expand Down

0 comments on commit 37bfd14

Please sign in to comment.