Skip to content

Commit

Permalink
Merge pull request #2744 from saucelabs/devx-2835
Browse files Browse the repository at this point in the history
docs: Document the retain feature
  • Loading branch information
mhan83 authored Apr 23, 2024
2 parents d7cc774 + f4afe3d commit 3a10ca9
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 3 deletions.
29 changes: 26 additions & 3 deletions docs/web-apps/automated-testing/_partials/_advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,35 @@ This feature is highly experimental.

## Attaching Test Assets

Any test assets created by your tests at runtime (such as logs, screenshots or reports) you wish to retain along with your test results must be placed in the `__assets__` directory of your project root folder. On Sauce Labs VMs, this path is relative to the current working directory.
By default, any test assets created by your tests at runtime (such as logs, screenshots or reports) you wish to retain along with your test results must be placed in the `__assets__` directory of your project root folder. On Sauce Labs VMs, this path is relative to the current working directory.

### Attaching entire directories

In situations where you want to preserve the file structure of your assets (e.g. a multi-page HTML report),
you can use the `retain` feature to define a directory to archive and store as a test asset.

### Handling nested assets

:::note Nested Paths
Nested assets are stored **flat** in Sauce Labs. A test asset like `__assets__/mylogs/log.txt` would therefore be stored and available for download as `log.txt`.
Please keep that in mind when creating custom assets, as examples like `__assets__/mylogs/log.txt` and `__assets__/myotherlogs/log.txt` would eventually collide when persisted.
:::

For Cypress and Playwright, there are cases where you may want to override this default behavior; e.g. your test framework generates
an HTML report and you want to preserve the entire report directory and don't want the individual files to
be flattened and automatically attached as described above. In that case, you can set an environment variable
in your saucectl config to opt out of the default behaviour. When set, the configured output directory
for the test run will be honoured; e.g. it won't be overridden to `__assets__/`.

```yaml title= "example configuration"
artifacts:
retain:
report-directory: archived-report.zip

env:
SAUCE_SYNC_WEB_ASSETS: "true"
```
When configured this way, the directory named `report-directory` will be archived as `archived-report.zip`.
To maintain backwards compatibility with our UI, some asset types (e.g. images, logs, etc.) in `report-directory` will still be automatically copied over to `__assets__/` and attached to the test results.

## Setting up a Proxy

Expand Down
29 changes: 29 additions & 0 deletions docs/web-apps/automated-testing/cucumberjs-playwright/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,35 @@ artifacts:

---

### `retain`

<p><small>| OPTIONAL | OBJECT |</small></p>

Define directories to archive and retain as a test asset at the end of a test run. Archived test assets can
be downloaded automatically using the `download` configuration, via the
[REST API](/dev/api/jobs/#get-a-job-asset-file), or through the test details page.

```yaml
artifacts:
retain:
source-directory: destination-archive.zip
download:
when: always
match:
- destination-archive.zip
directory: ./artifacts/
```

:::note
The source and destination will be relative to the `rootDir` defined in your configuration.
:::

:::note
The destination archive must have a .zip file extension.
:::

---

### `download`

<p><small>| OPTIONAL | OBJECT |</small></p>
Expand Down
32 changes: 32 additions & 0 deletions docs/web-apps/automated-testing/cypress/yaml/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,13 @@ Specifies how to manage test artifacts, such as logs, videos, and screenshots.
```yaml
artifacts:
cleanup: true
retain:
generated-report-dir: report.zip
download:
when: always
match:
- junit.xml
- report.zip
directory: ./artifacts/
```

Expand All @@ -635,6 +638,35 @@ artifacts:

---

### `retain`

<p><small>| OPTIONAL | OBJECT |</small></p>

Define directories to archive and retain as a test asset at the end of a test run. Archived test assets can
be downloaded automatically using the `download` configuration, via the
[REST API](/dev/api/jobs/#get-a-job-asset-file), or through the test details page.

```yaml
artifacts:
retain:
source-directory: destination-archive.zip
download:
when: always
match:
- destination-archive.zip
directory: ./artifacts/
```

:::note
The source and destination will be relative to the `rootDir` defined in your configuration.
:::

:::note
The destination archive must have a .zip file extension.
:::

---

### `download`

<p><small>| OPTIONAL | OBJECT |</small></p>
Expand Down
29 changes: 29 additions & 0 deletions docs/web-apps/automated-testing/playwright/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,35 @@ artifacts:

---

### `retain`

<p><small>| OPTIONAL | OBJECT |</small></p>

Define directories to archive and retain as a test asset at the end of a test run. Archived test assets can
be downloaded automatically using the `download` configuration, via the
[REST API](/dev/api/jobs/#get-a-job-asset-file), or through the test details page.

```yaml
artifacts:
retain:
source-directory: destination-archive.zip
download:
when: always
match:
- destination-archive.zip
directory: ./artifacts/
```

:::note
The source and destination will be relative to the `rootDir` defined in your configuration.
:::

:::note
The destination archive must have a .zip file extension.
:::

---

### `download`

<p><small>| OPTIONAL | OBJECT |</small></p>
Expand Down
29 changes: 29 additions & 0 deletions docs/web-apps/automated-testing/replay/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,35 @@ artifacts:

---

### `retain`

<p><small>| OPTIONAL | OBJECT |</small></p>

Define directories to archive and retain as a test asset at the end of a test run. Archived test assets can
be downloaded automatically using the `download` configuration, via the
[REST API](https://docs.saucelabs.com/dev/api/jobs/#get-a-job-asset-file), or through the test details page.

```yaml
artifacts:
retain:
source-directory: destination-archive.zip
download:
when: always
match:
- destination-archive.zip
directory: ./artifacts/
```

:::note
The source and destination will be relative to the `rootDir` defined in your configuration.
:::

:::note
The destination archive must have a .zip file extension.
:::

---

### `download`

<p><small>| OPTIONAL | OBJECT |</small></p>
Expand Down
29 changes: 29 additions & 0 deletions docs/web-apps/automated-testing/testcafe/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,35 @@ artifacts:

---

### `retain`

<p><small>| OPTIONAL | OBJECT |</small></p>

Define directories to archive and retain as a test asset at the end of a test run. Archived test assets can
be downloaded automatically using the `download` configuration, via the
[REST API](/dev/api/jobs/#get-a-job-asset-file), or through the test details page.

```yaml
artifacts:
retain:
source-directory: destination-archive.zip
download:
when: always
match:
- destination-archive.zip
directory: ./artifacts/
```

:::note
The source and destination will be relative to the `rootDir` defined in your configuration.
:::

:::note
The destination archive must have a .zip file extension.
:::

---

### `download`

<p><small>| OPTIONAL | OBJECT |</small></p>
Expand Down

0 comments on commit 3a10ca9

Please sign in to comment.