Skip to content

captain-examples/testcafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Captain working with TestCafe

This repo is a reference implementation of Captain consuming TestCafe results.

Layout

Path What it is
tests/ Two TestCafe fixture files (example-one.testcafe.js, example-two.testcafe.js) with 6 tests total.
local-page/ A vendored snapshot of TestCafe's public example page and its CSS/JS assets. Tests load this via file:// so the suite has no external dependencies. Two minimal patches are applied — see Local page patches.
bin/run-testcafe Wrapper that invokes the testcafe/testcafe Docker image with --network none and writes a JSON report to tmp/testcafe.json.
.captain/config.yaml Tells Captain to invoke ./bin/run-testcafe and read results from tmp/testcafe.json.
.github/workflows/ci.yml Runs captain run captain-examples-testcafe on every push and PR.

Running locally

./bin/run-testcafe

You'll see the standard TestCafe spec reporter output, and tmp/testcafe.json will be populated with the machine-readable report Captain consumes.

To exercise the full Captain integration locally (quarantine logic, retries, flake detection, upload to Captain Cloud), install the Captain CLI and run:

captain run captain-examples-testcafe

If you want to upload results to your Captain Cloud organization, also export RWX_ACCESS_TOKEN (more documentation here). Without the token, Captain runs in OSS mode — local-only, no upload.

Running in CI

The included GitHub Actions workflow does the same thing in CI. The runner already has Docker available, so the steps reduce to:

- uses: actions/checkout@v3
- uses: rwx-research/setup-captain@v1
- name: Run TestCafe
  run: captain run captain-examples-testcafe
  env:
    RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}

Add an RWX_ACCESS_TOKEN action secret to your repository to enable Captain Cloud uploads.

See the full documentation on test suite integration for the broader feature set.

Local page patches

local-page/ is a near-verbatim mirror of the upstream example page. Two patches were applied so the page works under file:// URLs:

  1. local-page/example/index.html — the upstream submit handler concatenates window.location.href + "thank-you.html", which produces a broken URL when href ends in index.html instead of a directory. Replaced with a trailing-segment substitution that works under both file:// and http://. The favicon link (an absolute /testcafe/favicon.ico path) is removed because it has no offline analogue.
  2. local-page/example/thank-you.html — the upstream page loads jQuery from the code.jquery.com CDN. Pointed at the already-vendored jQuery 1.12.4 instead. Favicon removed for the same reason as above.

Both patches are marked with Local patch: comments in the HTML.

About

How to integrate Captain with TestCafe

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors