Note that we have a code of conduct. Please follow it in your interactions with this project.
The core team is monitoring for pull requests. We will review your pull request and either merge it, request changes to it, or close it with an explanation.
Before submitting a pull request, please:
- Fork the repository and create your branch.
- Follow the setup instructions in this file.
- If you’re fixing a bug or adding code that should be tested, add tests!
- Ensure the test suite passes.
First, clone the hotwired/turbo
repository and install dependencies:
git clone https://github.com/hotwired/turbo.git
cd turbo
yarn install
Then create a branch for your changes:
git checkout -b <your_branch_name>
Tests are run through yarn
using Web Test Runner with Playwright for browser testing. Browser and runtime configuration can be found in web-test-runner.config.mjs
and playwright.config.ts
.
To begin testing, install the browser drivers:
yarn playwright install --with-deps
Then build the source. Because tests are run against the compiled source (and are themselves compiled) be sure to run yarn build
prior to testing. Alternatively, you can run yarn watch
to build and watch for changes.
yarn build
The test suite can be run with yarn
, using the test commands defined in package.json
. To run all tests in all configured browsers:
yarn test
To run just the unit or browser tests:
yarn test:unit
yarn test:browser
By default, tests are run in "headless" mode against all configured browsers (currently chrome
and firefox
). Use the --headed
flag to run in normal mode. Use the --project
flag to run against a particular browser.
yarn test:browser --project=firefox
yarn test:browser --project=chrome
yarn test:browser --project=chrome --headed
To run a single test file, pass its path as an argument. To run a particular test case, append its starting line number after a colon.
yarn test:browser src/tests/functional/drive_tests.ts
yarn test:browser src/tests/functional/drive_tests.ts:11
yarn test:browser src/tests/functional/drive_tests.ts:11 --project=chrome
Because tests are running headless in browsers, debugging can be difficult. Sometimes the simplest thing to do is load the test fixtures into the browser and navigate manually. To make this easier, a local web server is included.
To run the web server, ensure the source is built and start the server with yarn
:
yarn build
yarn start
The web server is available on port 9000, serving from the project root. Fixture files are accessible by path. For example, the file at src/tests/fixtures/rendering.html
will be accessible at http://localhost:9000/src/tests/fixtures/rendering.html.