You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/app/ci-workflows/upload-strategies/page.md
+190-1
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,196 @@ While uploading just failed test is good for saving resources, our recommendatio
8
8
{% /callout %}
9
9
10
10
## Upload failed tests only
11
-
By default, all test replays are uploaded no matter the result. If you want upload only the failed recordings, you can define the step to do so using `filter` property:
11
+
By default, all test replays are uploaded no matter the result. If you want to upload only the failed recordings, you can use the `filter` property in the plugin configuration:
12
+
13
+
{% tabs labels=["cypress", "playwright"] %}
14
+
{% tab %}
15
+
```js
16
+
exportdefaultdefineConfig({
17
+
e2e: {
18
+
setupNodeEvents(on, config) {
19
+
replayPlugin(on, config, {
20
+
upload:true,
21
+
apiKey:process.env.REPLAY_API_KEY,
22
+
filter:function (recording) {
23
+
// upload runtime crashes and any failed tests
24
+
return (
25
+
recording.status==="crashed"||
26
+
recording.metadata.test.result==="failed"
27
+
);
28
+
}
29
+
})
30
+
return config
31
+
},
32
+
},
33
+
})
34
+
```
35
+
{% /tab %}
36
+
{% tab %}
37
+
```js
38
+
const config:PlaywrightTestConfig= {
39
+
reporter: [["@replayio/playwright/reporter", {
40
+
apiKey:process.env.REPLAY_API_KEY,
41
+
upload:true
42
+
filter:function (recording) {
43
+
// upload runtime crashes and any failed tests
44
+
return (
45
+
recording.status==="crashed"||
46
+
recording.metadata.test.result==="failed"
47
+
);
48
+
}
49
+
}], ['line']],
50
+
projects: [
51
+
{
52
+
name:"replay-chromium",
53
+
use: { ...replayDevices["Replay Chromium"] as any },
54
+
}
55
+
],
56
+
};
57
+
exportdefaultconfig;
58
+
```
59
+
{% /tab %}
60
+
{% /tabs %}
61
+
62
+
63
+
## Upload failed and flaky Cypress tests
64
+
By default, all test replays are uploaded no matter the result. If you want to upload failed and flaky tests, you can use the `filter` property in the plugin configuration:
65
+
66
+
```js
67
+
exportdefaultdefineConfig({
68
+
e2e: {
69
+
setupNodeEvents(on, config) {
70
+
replayPlugin(on, config, {
71
+
upload:true,
72
+
apiKey:process.env.REPLAY_API_KEY,
73
+
filter:function (recording) {
74
+
// upload runtime crashes and recordings with any tests that failed
The recording metadata includes some details about the source control including the repository and branch name which can also be used to filter your uploads. The example below uploads all recordings from the `main` branch:
90
+
91
+
{% tabs labels=["cypress", "playwright"] %}
92
+
{% tab %}
93
+
```js
94
+
exportdefaultdefineConfig({
95
+
e2e: {
96
+
setupNodeEvents(on, config) {
97
+
replayPlugin(on, config, {
98
+
upload:true,
99
+
apiKey:process.env.REPLAY_API_KEY,
100
+
filter:function (recording) {
101
+
returnrecording.metadata.source.branch==="main";
102
+
}
103
+
})
104
+
return config
105
+
},
106
+
},
107
+
})
108
+
```
109
+
{% /tab %}
110
+
{% tab %}
111
+
```js
112
+
const config:PlaywrightTestConfig= {
113
+
reporter: [["@replayio/playwright/reporter", {
114
+
apiKey:process.env.REPLAY_API_KEY,
115
+
upload:true
116
+
filter:function (recording) {
117
+
returnrecording.metadata.source.branch==="main";
118
+
}
119
+
}], ['line']],
120
+
projects: [
121
+
{
122
+
name:"replay-chromium",
123
+
use: { ...replayDevices["Replay Chromium"] as any },
124
+
}
125
+
],
126
+
};
127
+
exportdefaultconfig;
128
+
```
129
+
{% /tab %}
130
+
{% /tabs %}
131
+
132
+
133
+
## Upload some passing runs
134
+
135
+
If you've adopted one the configurations above but would also like to periodically upload all replays for a test run, you can add a condition to the filter that returns `true` for a given test run id. This is only one possible implementation of this approach and you're welcome to adopt others such as using external environment variables.
0 commit comments