|
| 1 | +--- |
| 2 | +id: provider-plugin |
| 3 | +title: Provider Plugin |
| 4 | +sidebar_label: Provider Plugin |
| 5 | +--- |
| 6 | + |
| 7 | +# TestCafe Provider Plugin |
| 8 | + |
| 9 | +TestCafe can also connect to Sauce Labs _remotely_ via our [Provider Plugin](https://github.com/saucelabs/testcafe-provider). |
| 10 | + |
| 11 | +Unlike [saucectl](/dev/cli/saucectl/), which transmits and runs your TestCafe |
| 12 | +tests directly on a Sauce Labs VM, the Sauce Labs [Provider Plugin](https://github.com/saucelabs/testcafe-provider) |
| 13 | +allows TestCafe to connect to a browser session remotely, allowing for a greater |
| 14 | +project setup flexibility. |
| 15 | + |
| 16 | +We recommend that you give both approaches a try and pick the one that suits |
| 17 | +your use case best. |
| 18 | + |
| 19 | +:::note |
| 20 | +This plugin is currently in beta. We caution against using it in production |
| 21 | +pipelines. We do seek feedback and encourage you to report any issues you |
| 22 | +encounter. |
| 23 | +::: |
| 24 | + |
| 25 | +## Requirements |
| 26 | + |
| 27 | +- Node.js 20+ |
| 28 | +- [TestCafe Sauce Labs Browser Provider Plugin](https://github.com/saucelabs/testcafe-provider) |
| 29 | +- [TestCafe Sauce Labs Reporter](https://github.com/saucelabs/testcafe-reporter) |
| 30 | +- [Sauce Connect](/secure-connections/sauce-connect-5) |
| 31 | + |
| 32 | +## Install |
| 33 | + |
| 34 | +Install the provider plugin and the reporter: |
| 35 | +```shell |
| 36 | +npm install testcafe-browser-provider-sauce |
| 37 | +npm install testcafe-reporter-saucelabs |
| 38 | +``` |
| 39 | + |
| 40 | +## Start Tunnel |
| 41 | + |
| 42 | +A tunnel is necessary for the remote browser to establish a connection back to |
| 43 | +TestCafe. |
| 44 | + |
| 45 | +```shell |
| 46 | +sc run -u <your-user> -k <your-access-key> --region us-west --tunnel-name <your-tunnel> |
| 47 | +``` |
| 48 | + |
| 49 | +For more details, please follow our [Sauce Connect Quickstart](/secure-connections/sauce-connect-5/quickstart/) |
| 50 | +instructions. |
| 51 | + |
| 52 | +## Run TestCafe |
| 53 | + |
| 54 | +Set the necessary environment variables. |
| 55 | + |
| 56 | +```shell |
| 57 | +export SAUCE_USERNAME=your-user |
| 58 | +export SAUCE_ACCESS_KEY=your-access-key |
| 59 | +export SAUCE_TUNNEL_NAME=your-tunnel |
| 60 | +``` |
| 61 | + |
| 62 | +Verify that the provider has been properly installed and is able to talk to |
| 63 | +Sauce Labs by asking TestCafe to print out a list of supported remote browsers: |
| 64 | +```shell |
| 65 | +testcafe -b sauce |
| 66 | +``` |
| 67 | + |
| 68 | +You are ready to run tests, using a browser alias that the previous command |
| 69 | +returned: |
| 70 | +```shell |
| 71 | +testcafe "sauce:chrome@latest:Windows 11" path/to/test/file.js --reporter saucelabs |
| 72 | +``` |
| 73 | + |
| 74 | +## Limitations |
| 75 | + |
| 76 | +- TestCafe may incorrectly report the platform of a remote browser session, such |
| 77 | +as mistaking Windows 11 for Windows 10. |
0 commit comments