f388a3d550
* Add 'script/deploy' to enable manual deploys to Heroku * Pass API tokens into 'deploy-to-staging' module usage * Construct Octokit instance to pass in * Get PR branch name and verify state * Reorganize * Rename option to 'octokit' * Add missing option * Actually use the convenience methods for convenience * Simplify top-level script * Top-level script revisions * Add parse-pr-url module * Add create-staging-app-name module * Remove misplaced comment * Pass in owner * Use owner param * More variables * Pass owner along more * Correct prNumber param reference * Add WIP deploy-to-staging module * Prevent 'scripts/' and '.github/actions-scripts/' files from being modified in open source repo * Extract PR author earlier * Add note about optionally supplying DOCUBOT_REPO_PAT env var * Override Heroku env var during AppSetup creation instead of later to avoid triggering a second deploy * Updates to deploy-to-staging module * Lots of updates * Add dyno start-up monitoring and warmup requests * Ignore 'script/deploy' in the repository-references test * Correct path to Octokit helper * Temporarily add a 'gha-' prefix to environment names * Log whole error if terminal. Good for Octokit errors! * Correct Octokit preview configuration * Add more logging around Heroku build and release * Added more timings to log messages * Monitor dyno states specifically from the dyno list view to avoid 404 oddities when Free dynos are dropped and non-Free dynos are added * Don't wait for AppSetup status as it includes the Build time * Updating logging since we don't see DeploymentStatus update messages in the UI =( * Remove commented out code * Refactor to extract more properties from the PR object * Fix reference to pull request number * Increase Heroku polling intervals from 2.5 seconds to 5 seconds * Remove unhelpful createDeploymentStatus API calls * Workaround Heroku's secondary release upon app creation |
||
---|---|---|
.. | ||
browser | ||
content | ||
fixtures | ||
graphql | ||
helpers | ||
javascripts | ||
linting | ||
meta | ||
rendering | ||
routing | ||
unit | ||
README.md |
README.md
Tests
It's not strictly necessary to run tests locally while developing: You can always open a pull request and rely on the CI service to run tests for you, but sometimes it's helpful to run tests locally before pushing your changes to GitHub.
Test are written using jest, a framework maintained by Facebook and used by many teams at GitHub. Jest is convenient in that it provides everything: a test runner, an assertion library, code coverage analysis, custom reporters for different types of test output, etc.
Install optional dependencies
We typically rely on CI to run our tests, so we consider some large test-only dependencies optional (for example, puppeteer). In order to run the tests locally you'll need to make sure optional dependencies are installed by running:
npm ci --include=optional
If you run into the error "Could not find expected browser (chrome) locally" you may need to manually install the expected chromium version with:
node node_modules/puppeteer/install.js
Running all the tests
Once you've followed the development instructions above, you can run the entire test suite locally:
script/test # or `npm test`
Watching all the tests
You can also run a script that will continually watch for changes and re-run the tests any time a change is made. This command will notify you when tests change to and from a passing or failing state, and will also print out a test coverage report, so you can see what files are in need of tests.
npm run test-watch
Testing individual files
If you're making changes to a specific file and don't want to run the entire
test suite, you can pass an argument to the jest
testing tool:
jest __tests__/page.js
The argument doesn't have to be a fully qualified file path. It can also be a portion of a filename:
jest page # runs tests on __tests__/page.js and __tests__/pages.js
Linting
To validate all your JavaScript code (and auto-format some easily reparable mistakes), run the linter:
npm run lint
Broken link test
This test checks all internal links and image references in the English site. To run it locally (takes about 60 seconds):
npx jest links-and-images
It checks images, anchors, and links for every version of every page.
It reports five types of problems:
- Broken image references
- Example:
/assets/images/foo.png
wherefoo.png
doesn't exist.
- Example:
- Broken same-page anchors
- Example:
#foo
where the page does not have a headingFoo
.
- Example:
- Broken links due to page not found
- Example:
/github/using-git/foo
where there is nofoo.md
file at that path.
- Example:
- Broken links due to versioning
- Example: an unversioned link to a Dotcom-only article in a page that has Enterprise versions.
- Broken anchors on links
- Example:
/some/valid/link#bar
where the linked page can be found but it does not have a headingBar
.
- Example: