-
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
Only save test data for tests run with Replay browser #586
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@replayio/playwright": patch | ||
--- | ||
|
||
Only save test data for tests run with Replay browser |
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 |
---|---|---|
|
@@ -446,12 +446,7 @@ export default class ReplayReporter< | |
return; | ||
} | ||
|
||
if (this._testRunShardIdPromise) { | ||
return; | ||
} | ||
|
||
this._testRunShardIdPromise = this._startTestRunShard(); | ||
this._pendingWork.push(this._testRunShardIdPromise); | ||
// Don't event record test metadata yet unless/until a test is run with the Replay browser (see onTestBegin) | ||
bvaughn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private async _startTestRunShard(): Promise<TestRunPendingWork> { | ||
|
@@ -673,6 +668,15 @@ export default class ReplayReporter< | |
onTestBegin(testExecutionId?: string, metadataFilePath = getMetadataFilePath("REPLAY_TEST", 0)) { | ||
logger.info("OnTestBegin:Started", { testExecutionId }); | ||
|
||
if (this._apiKey) { | ||
if (!this._testRunShardIdPromise) { | ||
bvaughn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// This method won't be called until a test is run with the Replay browser | ||
// We shouldn't save any test metadata until that happens | ||
this._testRunShardIdPromise = this._startTestRunShard(); | ||
this._pendingWork.push(this._testRunShardIdPromise); | ||
} | ||
} | ||
|
||
this._errors = []; | ||
const metadata = { | ||
...(this._baseMetadata || {}), | ||
|
@@ -1230,14 +1234,14 @@ export default class ReplayReporter< | |
numUploaded = uploaded.length; | ||
|
||
if (uploaded.length > 0) { | ||
output.push(`\n🚀 Successfully uploaded ${uploads.length} recordings:\n`); | ||
output.push(`\n🚀 Successfully uploaded ${uploads.length} recordings:`); | ||
const sortedUploads = sortRecordingsByResult(uploads); | ||
sortedUploads.forEach(r => { | ||
output.push( | ||
` ${getTestResultEmoji(r)} ${(r.metadata.title as string | undefined) || "Unknown"}` | ||
`\n ${getTestResultEmoji(r)} ${(r.metadata.title as string | undefined) || "Unknown"}` | ||
); | ||
output.push( | ||
` ${process.env.REPLAY_VIEW_HOST || "https://app.replay.io"}/recording/${r.id}\n` | ||
` ${process.env.REPLAY_VIEW_HOST || "https://app.replay.io"}/recording/${r.id}` | ||
Comment on lines
-1233
to
+1242
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 was leaving a goofy trailing line too, after the last test. |
||
); | ||
}); | ||
} | ||
|
@@ -1256,7 +1260,9 @@ export default class ReplayReporter< | |
numUploaded, | ||
}); | ||
|
||
log(output.join("\n")); | ||
if (output.length > 0) { | ||
log(output.join("\n")); | ||
} | ||
bvaughn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return results; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's unclear to me when it can happen but, in theory (aka according to the types), the project is optional.... In such a scenario the tested value resolves to
undefined
here and based on that code will continue to process this. I wonder if that's intentional behavior or notThere 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.
It was also unclear to me about when this could happen. (How would Playwright even know which browser to use if there was no project?)
I just did some local testing and realized that I can comment out the
projects
config block entirely and Playwright still works:Adding some logging to the reporter I see that we still get a project back in this case though:
So the logic I have here would still hold. That being said, maybe it's safer to switch back to my original approach: