Package Scripts

Jonathan Sharpe edited this page Nov 8, 2018 · 5 revisions

We have provided a lot of developer automation for common tasks using the "scripts" section in the package.json. Below is a guide to some of the scripts you may find yourself using.


  • yarn install:all: install all of the client and server dependencies.

  • yarn client ...: run the provided command in the client directory, e.g. yarn client add [whatever] allows you to install a new client dependency.

  • yarn dev: runs the app in development mode, where changes to the client or server code will cause a reload. This uses nodemon to watch the server files and the create-react-app server for the client. In this mode you can visit the client at http://localhost:4200 and any requests will be proxied to the server (running on port 3000). Note that the browser will reload automatically if the client code changes, but you have to refresh the page manually to see changes in the server code. This also runs the Zapier spy.

  • yarn test:client:watch: watches the code in the client directory and re-runs the appropriate unit and integration tests whenever anything changes.

  • yarn test:scripts:watch: as above but for the scripts directory.

  • yarn test:server:watch: as above but for the server directory.

  • yarn e2e:dev: runs the end-to-end tests (see below) against the development mode of the application.

  • yarn cypress:dev: opens the Cypress UI and targets the development mode app, allowing you to see exactly what's happening in the end-to-end tests.

  • yarn mm migrate: apply the migrations specified in server/migrations to the local database (or the database specified with the DATABASE_URL environment variable).

  • yarn mm create [name]: create a new migration file; see mongodb-migrations for details.


  • yarn lint: checks all JavaScript code against the project style rules using ESLint and uses Flow to type-check the client code. You can also run lint:fix to automatically fix simple errors.

  • yarn test: runs the unit and integration tests for the client, script and server code.

  • yarn test:cover: runs all of the unit and integration tests and generates code coverage reports.

  • yarn e2e: runs the end-to-end tests, simulating a user interacting with the application in a browser, using Cypress. By default this runs against the app in production mode, on port 3000.

  • yarn e2e:ci: simultaneously starts the app in production mode (on port 3100 to avoid any conflicts) and runs the end-to-end tests against it, after waiting for the app to start. This also runs the Zapier spy.

  • yarn ship: runs linting, flow checking, unit and integration testing and the end-to-end CI test. This is executed by husky when you try to push your git commits to a remote, as a final check that everything works correctly*.


  • yarn start: runs the app in the production mode, by building the React app, copying the resulting files over to the Express app's static/ directory, then starting the Express app. You can then visit the application at http://localhost:3000 (or whatever port you specify with the PORT environment variable). Note that this will not start the Zapier spy, so you need to provide an EMAIL_WEBHOOK if you want to test the password reset.


  • yarn zapier: runs the Zapier spy (see e2e/fixtures/zapierSpy.js), which accepts any POST request to / and stores the request bodies for later recovery via the /_calls endpoint. This is used by the dev and e2e:ci scripts to allow testing of the password reset flow.

  • yarn generate-reports: each implementing partner gets a new report to fill in every month, created by this script. In production we're using PCF Scheduler to run this task on the first of every month, but you can also run this locally for testing (it will only generate one report per implementing partner per month, even if you run it more than once).

  • yarn hash-password [password]: uses bcrypt to create a hashed version of the supplied password to store in the database.

  • yarn send-due-emails: sends emails to anyone whose report is due in the next week, via the specified EMAIL_WEBHOOK.

* If you're making non-code changes, e.g. updating the documentation, you can include [ci skip] in the commit message to skip the Travis build and use the --no-verify flag to git push to skip the Husky hook.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.