Skip to content

Commit

Permalink
fix: caller filename in dynamic testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
balazs4 committed May 17, 2021
1 parent 536c5ec commit 3149334
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ module.exports.test = async (description, assertion = null) => {
: txt
);
};
const [, , caller] = new Error().stack.split('at ');
const [, filename] = caller.match(/\((.*)\)/);
const [, caller] = new Error().stack
.split('\n')
.filter((x) => x.startsWith(' at'));
const [, filename] = caller.match(/\((.*)\)/) || [
,
caller.replace(' at', '').trim(),
];
const origin =
process.stdout.hasColors && process.stdout.hasColors() === true
? `\x1b[2m${filename}\x1b[0m`
: filename;

const name =
const name =
process.stdout.hasColors && process.stdout.hasColors() === true
? `\x1b[1m${description}\x1b[0m`
: description;
Expand Down

0 comments on commit 3149334

Please sign in to comment.