Skip to content

Commit

Permalink
Hacky fix for each test location with jest-circus
Browse files Browse the repository at this point in the history
  • Loading branch information
apexskier committed Aug 16, 2020
1 parent 78595d1 commit 7b9a72d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions e2e/__tests__/locationInResults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ it('adds correct location info when provided with flag', () => {
});

expect(assertions[3].location).toEqual({
column: 22,
column: isJestCircusRun() ? 1 : 22,
line: 24,
});

expect(assertions[4].location).toEqual({
column: 22,
column: isJestCircusRun() ? 1 : 22,
line: 24,
});

Expand All @@ -72,12 +72,12 @@ it('adds correct location info when provided with flag', () => {
});

expect(assertions[8].location).toEqual({
column: isJestCircusRun() ? 25 : 24,
column: isJestCircusRun() ? 3 : 24,
line: 41,
});

expect(assertions[9].location).toEqual({
column: isJestCircusRun() ? 25 : 24,
column: isJestCircusRun() ? 3 : 24,
line: 41,
});
});
6 changes: 5 additions & 1 deletion packages/jest-circus/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ export const makeSingleTestResult = (
let location = null;
if (includeTestLocationInResult) {
const stackLine = test.asyncError.stack.split('\n')[1];
const parsedLine = stackUtils.parseLine(stackLine);
let parsedLine = stackUtils.parseLine(stackLine);
if (parsedLine?.file?.includes('/jest-each/')) {
const stackLine = test.asyncError.stack.split('\n')[4];
parsedLine = stackUtils.parseLine(stackLine);
}
if (
parsedLine &&
typeof parsedLine.column === 'number' &&
Expand Down

0 comments on commit 7b9a72d

Please sign in to comment.