Skip to content

Commit

Permalink
docs: Add example showing usePackageLock (#56)
Browse files Browse the repository at this point in the history
* Add example demonstrating test time dependencies

* Add link to external dep repo

* Add new example to test workflow

* apply best practice for usePackageLock

* no chrome tests until fixed upstream

* Remove packages from README
  • Loading branch information
mhan83 authored Nov 7, 2024
1 parent 0317adf commit 0586a89
Show file tree
Hide file tree
Showing 8 changed files with 5,731 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ jobs:
with:
working-directory: ./examples/browser_profile
concurrency: 10

react:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run saucectl
uses: saucelabs/saucectl-run-action@v4
with:
working-directory: ./examples/react
concurrency: 10

36 changes: 36 additions & 0 deletions examples/react/.sauce/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1alpha
kind: testcafe
sauce:
region: us-west-1
concurrency: 2
metadata:
tags:
- e2e
- release team
- other tag
testcafe:
version: 3.6.2
configFile: .testcaferc.js
# Controls what files are available in the context of a test run (unless explicitly excluded by .sauceignore).
rootDir: ./
suites:
- name: "testcafe react example - firefox"
browserName: "firefox"
src:
- "tests/*.test.ts"
platformName: "Windows 11"

# Controls what artifacts to fetch when the suites have finished.
artifacts:
download:
when: always
match:
- console.log
directory: ./artifacts/

reporters:
spotlight: # Prints an overview of failed or otherwise interesting jobs.
enabled: true

npm:
usePackageLock: true
1 change: 1 addition & 0 deletions examples/react/.sauceignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions examples/react/.testcaferc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
disableNativeAutomation: true,
};
48 changes: 48 additions & 0 deletions examples/react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# saucectl TestCafe & React Example

This example demonstrates how to use a test time dependency when running your
TestCafe tests with saucectl.

## What You'll Need

The steps below illustrate one of the quickest ways to get set up. If you'd like
a more in-depth guide, please check out our
[documentation](https://docs.saucelabs.com/dev/cli/saucectl/#installing-saucectl).

### Install `saucectl`

```sh
npm install -g saucectl
```

### Set Your Sauce Labs Credentials

```sh
saucectl configure
```

## Running The Examples

Simply check out this repo, navigate into `examples/react` and run the
command below :rocket:

```sh
saucectl run
```

## Configuration

The test in this example requires the
[testcafe-react-selectors](https://github.com/DevExpress/testcafe-react-selectors)
package so it needs to be available in the test environment. We can define a
list of packages to install before test execution in the saucectl configuration
file.

```yaml
npm:
usePackageLock: true
```
Enabling the `usePackageLock` option ensures that the project's package.json and
package-lock.json are used during package installation. In most cases, this will
reduce the time needed for package installation.
Loading

0 comments on commit 0586a89

Please sign in to comment.