Please note we have a code of conduct, please follow it in all your interactions with the 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 make sure the following is done:
- Fork the repository and create your branch from main.
- Run
yarnin the repository root. - If you’ve fixed a bug or added code that should be tested, add tests!
- Ensure the test suite passes (
yarn build && yarn test).
During the process of developing the library locally we first have to check out the repository and create a branch from main.
git clone https://github.com/hotwired/turbo.git
cd turbo
yarngit checkout -b '<your_branch_name>'Once you are done developing the feature or bug fix you have 2 options:
- Run the test suite
- Run a local webserver and checkout your changes manually
The library is tested by running the test suite (found in: src/tests/*) against headless browsers. The browsers are setup in intern.json and playwright.config.ts. Check them out to see the used browser environments.
To override the ChromeDriver version, declare the CHROMEVER environment
variable.
First, install the drivers to test the suite in browsers:
yarn playwright install --with-depsThe tests are using the compiled version of the library and they are themselves also compiled. To compile the tests and library and watch for changes:
yarn watchTo run the unit tests:
yarn test:unitTo run the browser tests:
yarn test:browserTo run the browser suite against a particular browser (one of
chrome|firefox), pass the value as the --project=$BROWSER flag:
yarn test:browser --project=chromeTo run the browser tests in a "headed" browser, pass the --headed flag:
yarn test:browser --project=chrome --headedPlease add your tests in the test files closely related to the feature itself. For example when touching the src/core/drive/page_renderer.ts your test will probably endup in the src/tests/functional/rendering_tests.ts.
The html files needed for the tests are stored in: src/tests/fixtures/
To focus on single test, pass its file path:
yarn test:browser TEST_FILEWhere the TEST_FILE is the name of test you want to run. For example:
yarn test:browser src/tests/functional/drive_tests.ts
To execute a particular test, append :LINE where LINE is the line number of
the call to test("..."):
yarn test:browser src/tests/functional/drive_tests.ts:11Since the tests are running in headless browsers it's not easy to debug them easily without using the debugger. Sometimes it's easier to run the supplied webserver and manually click through the test fixtures.
To run the webserver:
yarn startThis requires a build (via yarn build), or a separate process running yarn watch.
The webserver is available on port 9000. Since the webserver is run from the root of the project the fixtures can be found using the same path as they have in the project itself, so src/tests/fixtures/rendering.html makes: http://localhost:9000/src/tests/fixtures/rendering.html
Depending on your operating system you are able to open the page using:
open http://localhost:9000/src/tests/fixtures/rendering.html