-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Error codeframes in retry failures display the code that produce…
…d the error (#30962) * change how user invocation stacks are prepared, for more flexibility * build darwin and persist artifacts for this branch * changelog * add implicit dependencies to @packages/extension so things build in the right order * note about binary testing for error_utils and stack_utils * changelog * Update packages/driver/test/unit/cypress/err_utils.spec.ts Co-authored-by: Bill Glesias <[email protected]> --------- Co-authored-by: Bill Glesias <[email protected]>
- Loading branch information
1 parent
2a57c8b
commit 37ad232
Showing
9 changed files
with
191 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
73 changes: 73 additions & 0 deletions
73
packages/driver/test/unit/cypress/__fixtures__/getUserInvocationStack_stackFrames.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { vi, describe, it, expect, beforeEach } from 'vitest' | ||
|
||
// source_map_utils must be included in order for vite to mock it, even | ||
// if it isn't referenced. | ||
// eslint-disable-next-line | ||
import source_map_utils from '../../../src/cypress/source_map_utils' | ||
import errUtils from '../../../src/cypress/error_utils' | ||
import stackFrameFixture from './__fixtures__/getUserInvocationStack_stackFrames.json' | ||
|
||
vi.mock('../../../src/cypress/source_map_utils', () => { | ||
return { | ||
default: { | ||
getSourcePosition: vi.fn(), | ||
}, | ||
} | ||
}) | ||
|
||
describe('err_utils', () => { | ||
beforeEach(() => { | ||
// @ts-expect-error | ||
global.Cypress = { | ||
config: vi.fn(), | ||
} | ||
|
||
vi.resetAllMocks() | ||
}) | ||
|
||
describe('getUserInvocationStack', () => { | ||
const { invocationFile, line, column, scenarios } = stackFrameFixture | ||
|
||
let stack: string | ||
|
||
class MockError { | ||
name = 'CypressError' | ||
get userInvocationStack () { | ||
return stack | ||
} | ||
} | ||
|
||
const state = () => undefined | ||
|
||
for (const scenario of scenarios) { | ||
const { browser, build, testingType, stack: scenarioStack } = scenario | ||
|
||
describe(`${browser}:${build}:${testingType}`, () => { | ||
beforeEach(() => { | ||
stack = scenarioStack | ||
}) | ||
|
||
it('returns the userInvocationStack with no leading internal cypress codeframes', () => { | ||
const invocationStack = errUtils.getUserInvocationStack(new MockError(), state) | ||
|
||
expect(invocationStack).not.toBeUndefined() | ||
|
||
const [first, second] = (invocationStack as string).split('\n') | ||
|
||
const invocationFrame = second ?? first | ||
|
||
expect(invocationFrame).toContain(`${invocationFile}:${line}:${column}`) | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,10 @@ | |
"lib", | ||
"theme" | ||
], | ||
"nx": {} | ||
"nx": { | ||
"implicitDependencies": [ | ||
"@packages/server", | ||
"@packages/socket" | ||
] | ||
} | ||
} |
37ad232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
37ad232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
37ad232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
37ad232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: