Skip to content

Commit

Permalink
add testcafe provider plugin (#2899)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexplischke committed Sep 17, 2024
1 parent 67e31ee commit 27d9fd2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/web-apps/automated-testing/testcafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import useBaseUrl from '@docusaurus/useBaseUrl';

[TestCafe](https://github.com/DevExpress/testcafe) is a testing framework that you can use to test your web apps remotely on Sauce Labs cloud using the [`saucectl` CLI](/dev/cli/saucectl).
[TestCafe](https://github.com/DevExpress/testcafe) is a testing framework that
you can use to test your web apps remotely on Sauce Labs cloud using the [`saucectl` CLI](/dev/cli/saucectl).

## System Requirements

Expand Down Expand Up @@ -171,9 +172,13 @@ Sauce Labs supports the following test configurations for TestCafe:

### TestCafe Plugins for Sauce Labs

If you prefer to stay in TestCafe, try the new [TestCafe Sauce Labs Plugin](https://github.com/DevExpress/testcafe-browser-provider-saucelabs). Connect to your Sauce Labs account from within your TestCafe project to configure and run your tests directly from TestCafe.
If all you want is to publish your TestCafe test results to Sauce Labs (but not run on Sauce Labs), check out our [TestCafe reporter](https://github.com/saucelabs/testcafe-reporter)!
If you prefer to run your tests directly from TestCafe against a remote Sauce
Labs browser, try our [TestCafe Provider Plugin](provider-plugin).

If all you want is to publish your TestCafe test results to Sauce Labs, but not
run _on_ Sauce Labs or use a Sauce Labs provided browser, check out our
[TestCafe Reporter](https://github.com/saucelabs/testcafe-reporter)!

## Limitations

Please check the [Limitations Page](testcafe/limitations.md).
Please check the [Limitations Page](limitations).
77 changes: 77 additions & 0 deletions docs/web-apps/automated-testing/testcafe/provider-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: provider-plugin
title: Provider Plugin
sidebar_label: Provider Plugin
---

# TestCafe Provider Plugin

TestCafe can also connect to Sauce Labs _remotely_ via our [Provider Plugin](https://github.com/saucelabs/testcafe-provider).

Unlike [saucectl](/dev/cli/saucectl/), which transmits and runs your TestCafe
tests directly on a Sauce Labs VM, the Sauce Labs [Provider Plugin](https://github.com/saucelabs/testcafe-provider)
allows TestCafe to connect to a browser session remotely, allowing for a greater
project setup flexibility.

We recommend that you give both approaches a try and pick the one that suits
your use case best.

:::note
This plugin is currently in beta. We caution against using it in production
pipelines. We do seek feedback and encourage you to report any issues you
encounter.
:::

## Requirements

- Node.js 20+
- [TestCafe Sauce Labs Browser Provider Plugin](https://github.com/saucelabs/testcafe-provider)
- [TestCafe Sauce Labs Reporter](https://github.com/saucelabs/testcafe-reporter)
- [Sauce Connect](/secure-connections/sauce-connect-5)

## Install

Install the provider plugin and the reporter:
```shell
npm install testcafe-browser-provider-sauce
npm install testcafe-reporter-saucelabs
```

## Start Tunnel

A tunnel is necessary for the remote browser to establish a connection back to
TestCafe.

```shell
sc run -u <your-user> -k <your-access-key> --region us-west --tunnel-name <your-tunnel>
```

For more details, please follow our [Sauce Connect Quickstart](/secure-connections/sauce-connect-5/quickstart/)
instructions.

## Run TestCafe

Set the necessary environment variables.

```shell
export SAUCE_USERNAME=your-user
export SAUCE_ACCESS_KEY=your-access-key
export SAUCE_TUNNEL_NAME=your-tunnel
```

Verify that the provider has been properly installed and is able to talk to
Sauce Labs by asking TestCafe to print out a list of supported remote browsers:
```shell
testcafe -b sauce
```

You are ready to run tests, using a browser alias that the previous command
returned:
```shell
testcafe "sauce:chrome@latest:Windows 11" path/to/test/file.js --reporter saucelabs
```

## Limitations

- TestCafe may incorrectly report the platform of a remote browser session, such
as mistaking Windows 11 for Windows 10.
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,7 @@ module.exports = {
items: [
'web-apps/automated-testing/testcafe',
'web-apps/automated-testing/testcafe/quickstart',
'web-apps/automated-testing/testcafe/provider-plugin',
'web-apps/automated-testing/testcafe/yaml',
'web-apps/automated-testing/testcafe/advanced',
'web-apps/automated-testing/testcafe/limitations',
Expand Down

0 comments on commit 27d9fd2

Please sign in to comment.