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
Attach a value or a file from disk to the current test step. Some reporters show test step attachments. Either [`option: path`] or [`option: body`] must be specified, but not both. Calling this method will attribute the attachment to the step, as opposed to [`method: TestInfo.attach`] which stores all attachments at the test level.
23
+
24
+
For example, you can attach a screenshot to the test step:
[`method: TestStepInfo.attach`] automatically takes care of copying attached files to a
54
+
location that is accessible to reporters. You can safely remove the attachment
55
+
after awaiting the attach call.
56
+
:::
57
+
58
+
### param: TestStepInfo.attach.name
59
+
* since: v1.51
60
+
-`name` <[string]>
61
+
62
+
Attachment name. The name will also be sanitized and used as the prefix of file name
63
+
when saving to disk.
64
+
65
+
### option: TestStepInfo.attach.body
66
+
* since: v1.51
67
+
-`body` <[string]|[Buffer]>
68
+
69
+
Attachment body. Mutually exclusive with [`option: path`].
70
+
71
+
### option: TestStepInfo.attach.contentType
72
+
* since: v1.51
73
+
-`contentType` <[string]>
74
+
75
+
Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
76
+
77
+
### option: TestStepInfo.attach.path
78
+
* since: v1.51
79
+
-`path` <[string]>
80
+
81
+
Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
0 commit comments