-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed displayError
being incorrectly used for all tests attempts
#530
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@replayio/cypress": major | ||
--- | ||
|
||
Bumped the required peer dependency range on Cypress to `^13` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@replayio/cypress": patch | ||
--- | ||
|
||
Fixed an issue with `displayError` being incorrectly reused for all test attempts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
tests/fixtures | ||
tests/fixtures |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,11 +78,13 @@ function getTestsFromResults( | |
const tests = resultTests.flatMap<Test>((result, id) => { | ||
const scope = [...result.title]; | ||
const title = scope.pop()!; | ||
const lastAttemptIndex = result.attempts.length - 1; | ||
|
||
return result.attempts.map<Test>((a, attemptIndex) => ({ | ||
id: getIdForTest(result) ?? attemptIndex, | ||
// Cypress 10.9 types are wrong here ... duration doesn't exist but wallClockDuration does | ||
approximateDuration: a.duration || (a as any).wallClockDuration || 0, | ||
// those properties don't exist since Cypress 13: https://github.com/cypress-io/cypress/pull/27230 | ||
// TODO: remove it in PRO-640 | ||
approximateDuration: (a as any).duration || (a as any).wallClockDuration || 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the latest version of Cypress this is non-sensical. It will just always be 0. I'm afraid to remove it though, without confirming that devtools and dashboard would be fine without this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a Linear task + TODO comment to follow up here? Else it will get forgotten about. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, PRO-640 |
||
attempt: attemptIndex + 1, | ||
source: { | ||
title, | ||
|
@@ -96,12 +98,20 @@ function getTestsFromResults( | |
afterEach: [], | ||
main: [], | ||
}, | ||
error: result.displayError | ||
? { | ||
name: "DisplayError", | ||
message: result.displayError, | ||
} | ||
: null, | ||
// attempt.error is available here: | ||
// https://github.com/cypress-io/cypress/blob/61156808413be8b99264026323ce3abfb22c4c26/packages/server/lib/modes/results.ts#L20 | ||
// but it's lost when creating a public test result: | ||
// https://github.com/cypress-io/cypress/blob/61156808413be8b99264026323ce3abfb22c4c26/packages/server/lib/modes/results.ts#L111 | ||
// `.displayError` represents the error reported by the last attempt | ||
// for all of the previous attempts we rely on the search for the last errored step in `groupStepsByTest` | ||
// if an error is found there, it will be set on the test, the information set here is not overriden though | ||
Comment on lines
+105
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic is a little bit wonky but it makes sense. The It would be great to refactor this so we don't have to rely on a mutation elsewhere but that's out of this PR's scope |
||
error: | ||
attemptIndex === lastAttemptIndex && result.displayError | ||
? { | ||
name: "DisplayError", | ||
message: result.displayError, | ||
} | ||
: null, | ||
})); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,15 +82,15 @@ function handleReplayConnectResponse(v: unknown) { | |
} | ||
} | ||
|
||
function isReplayConnectCallbackCommand(cmd: Cypress.EnqueuedCommand) { | ||
function isReplayConnectCallbackCommand(cmd: Cypress.EnqueuedCommandAttributes) { | ||
return ( | ||
cmd.name === "then" && Array.isArray(cmd.args) && cmd.args[0] === handleReplayConnectResponse | ||
); | ||
} | ||
|
||
function shouldIgnoreCommand(cmd: Cypress.EnqueuedCommand | Cypress.CommandQueue) { | ||
function shouldIgnoreCommand(cmd: Cypress.EnqueuedCommandAttributes | Cypress.CommandQueue) { | ||
if (isCommandQueue(cmd)) { | ||
cmd = cmd.toJSON() as any as Cypress.EnqueuedCommand; | ||
cmd = cmd.toJSON() as any as Cypress.EnqueuedCommandAttributes; | ||
} | ||
|
||
if (isReplayConnectCallbackCommand(cmd)) { | ||
|
@@ -444,7 +444,7 @@ function register() { | |
// covert it using its toJSON method (which is typed wrong so we have to | ||
// cast it to any first) | ||
if (isCommandQueue(cmd)) { | ||
cmd = cmd.toJSON() as any as Cypress.EnqueuedCommand; | ||
cmd = cmd.toJSON() as any as Cypress.EnqueuedCommandAttributes; | ||
} | ||
|
||
const id = getReplayId( | ||
|
@@ -579,7 +579,7 @@ function register() { | |
logs: () => [], | ||
add: () => {}, | ||
get: (key?: any) => (!key ? log : log[key]), | ||
toJSON: () => log, | ||
toJSON: () => [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the previous version was completely crashing Cypress, the I verified that we can still render |
||
create: () => ({} as any), | ||
}; | ||
} else if (maybeCurrentAssertion?.get("type") !== "assertion") { | ||
|
@@ -591,7 +591,7 @@ function register() { | |
return; | ||
} | ||
|
||
if (shouldIgnoreCommand(maybeCurrentAssertion)) { | ||
if (!maybeCurrentAssertion || shouldIgnoreCommand(maybeCurrentAssertion)) { | ||
return; | ||
} | ||
|
||
|
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.
Cypress 13 was released almost one year ago (08/29/2023). We don't have any tests for this whole integration, trying to test compatibility manually with an extended range of versions is a nightmare. I don't feel we can quite guarantee compatibility right now with other versions, it's impractical.
If requested by clients we can always loosen up this range after manually confirming that a particular combination works. We'll release a new major of this package soon so I think we should grab the opportunity and bump this here.
Note that supporting more right now would require some extra work here, I changed this because I ran into typing problems (that likely were related to breaking changes in Cypress).
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.
I support this.