Clone this repo to your local machine
[email protected]:alphagov/di-authentication-frontend.gitClones the repository to the <your_folder_name directory.
Before you can run the frontend app against the backend you will need to configure some environment variables.
Create a copy of the .env.sample file and rename it .env and fill in below values:
ENVIRONMENT=development
API_BASE_URL=
FRONTEND_API_BASE_URL=
SESSION_EXPIRY=30000
SESSION_SECRET=123456
API_KEY=
ANALYTICS_COOKIE_DOMAIN=localhost
You can find the API_BASE_URL in Concourse under the outputs within the deploy-oidc-api-{environment} job, where {environment} is the name of the environment you want to connect to.
Run docker-compose up or the startup.sh script.
In docker-compose.yaml you will see three services which need to be started to run the frontend locally, the frontend itself, a lightweight stub client, and a redis instance.
When starting for the first time, or after a clean, the frontend will take a few minutes to start as node needs to install all the dependencies.
To find out if the application has started, open a console window on the frontend docker container and view the logs. If the server has started successfully you will see this message Server listening on port 3000. If this does not appear try forcing node to restart by updating one of the .njk files.
Navigate to the stub app http://localhost:2000. This acts like a local client to create a backend session and redirect to the start page.
Changes made locally will automatically be deployed after a few seconds. You should check the docker console to check that your changes have been picked up by the restart.
The unit tests have been written with Mocha and Supertest.
If the app is run in a container then the tests are run there too:
docker exec -it di-auth-frontend-dev /bin/sh
# yarn run test:unitYou can restart the app by re-running the startup.sh script, or restarting docker-compose.
For a clean start run ./startup.sh -c
Remember to run these commands in the docker container itself.
To run the app in development mode with nodemon watching the files
yarn devStarts a nodemon server serving the files from the dist/
directory.
To build the app
yarn buildTo run the built app
yarn startStarts a node server pointing to the entry point found in the build directory.
To run the unit tests
yarn test:unitRuns all unit tests found in the tests/unit/ directory
using mocha.
To run the integration tests
yarn test:integrationTo install dependencies, run yarn install
yarn installInstalls the dependencies required to run the application.
To get a coverage report
yarn test:coverageTo run lint checks
yarn lintChecks if the code conforms the linting standards.