diff --git a/e2e/__tests__/locationInResults.test.ts b/e2e/__tests__/locationInResults.test.ts index 39e2b0dfbe36..25808059c29c 100644 --- a/e2e/__tests__/locationInResults.test.ts +++ b/e2e/__tests__/locationInResults.test.ts @@ -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, }); @@ -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, }); }); diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index 82b4b78e52d4..ea32144d32be 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -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' &&