Skip to content

Commit

Permalink
fix(bun): file path is not parsed (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Mar 1, 2024
1 parent aa62c08 commit dad9498
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/helpers/parseAsssetion.ts
Expand Up @@ -23,11 +23,21 @@ const findFile = (error: Error) => {

for (const line of stackLines) {
if (!line.includes(basePath)) {
const match = line.match(/at\s(\/.+|file:\/\/\/.+)/i);
const match = line.match(
/at\s(\/.+|file:.+)|^(\s+)at\smodule\scode\s\((\/.+|file:.+)\)/i
);

// Node and Deno
if (match && match[1]) {
file = match[1];
break;
}

// Bun
if (match && match[3]) {
file = match[3];
break;
}
}
}

Expand Down Expand Up @@ -57,7 +67,7 @@ export const parseAssertion = (
} catch (error) {
if (error instanceof assert.AssertionError) {
const { code, actual, expected, operator } = error;
const absoultePath = findFile(error);
const absoultePath = findFile(error).replace(/file:/, '');
const file = path.relative(path.resolve(process.cwd()), absoultePath);

let message: string = '';
Expand Down

0 comments on commit dad9498

Please sign in to comment.