Skip to content
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

Remove filter function from test utils config #602

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/sharp-chicken-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@replayio/cypress": major
"@replayio/playwright": major
---

Remove deprecated `filter` function from test config
10 changes: 1 addition & 9 deletions packages/test-utils/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ export default class ReplayReporter<
private _apiKey?: string;
private _pendingWork: Promise<PendingWork | undefined>[] = [];
private _upload = false;
private _filter?: (r: RecordingEntry<TRecordingMetadata>) => boolean;
private _minimizeUploads = false;
private _uploadableResults: Map<string, UploadableTestResult<TRecordingMetadata>> = new Map();
private _testRunShardIdPromise: Promise<TestRunPendingWork> | null = null;
Expand Down Expand Up @@ -355,8 +354,6 @@ export default class ReplayReporter<
config.runTitle ||
getFallbackRunTitle();

this._filter = config.filter;

// RECORD_REPLAY_METADATA is our "standard" metadata environment variable.
// We suppress it for the browser process so we can use
// RECORD_REPLAY_METADATA_FILE but can still use the metadata here which
Expand Down Expand Up @@ -425,14 +422,12 @@ export default class ReplayReporter<
baseMetadata: this._baseMetadata,
upload: this._upload,
hasApiKey: !!this._apiKey,
hasFilter: !!this._filter,
});

mixpanelAPI.trackEvent("test-suite.begin", {
baseId: this._baseId,
runTitle: this._runTitle,
upload: this._upload,
hasFilter: !!this._filter,
});

if (!this._apiKey) {
Expand Down Expand Up @@ -1092,10 +1087,7 @@ export default class ReplayReporter<
}

this._pendingWork.push(
...toUpload
.flatMap(result => result.recordings)
.filter(r => (this._filter ? this._filter(r) : true))
.map(r => this._uploadRecording(r))
...toUpload.flatMap(result => result.recordings).map(r => this._uploadRecording(r))
);
}

Expand Down
8 changes: 3 additions & 5 deletions packages/test-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ export type UploadOptions = {
export interface ReplayReporterConfig<
TRecordingMetadata extends UnstructuredMetadata = UnstructuredMetadata
> {
runTitle?: string;
metadata?: Record<string, any> | string;
apiKey?: string;
metadata?: TRecordingMetadata;
metadataKey?: string;
runTitle?: string;
upload?: UploadOptions | boolean;
apiKey?: string;
/** @deprecated Use `upload.minimizeUploads` and `upload.statusThreshold` instead */
filter?: (r: RecordingEntry<TRecordingMetadata>) => boolean;
}