After cloning the project for the first time, run the following command to install required npm packages:
For all following commands in this section, you must be in the "client" directory
npm install
// do the following instead if you run into error messages and are using a newer node version (e.g. >v16)
npm install --legacy-peer-deps
Choose one of the following 2 methods to run the application locally for development.
Run one of the following scripts (they do they same thing), this will start the development server:
npm start
npm run start
After the development server has started successfully, visit http://localhost:3000
to visit the application.
As the application is intended to deploy via Google's Cloud Run, the application conveniently has a Dockerfile
to allow containerisation of this application.
If you choose to do build and serve the app with the Dockerfile, do the following steps:
# you are reminded to be in the "client" directory and docker is installed and running on your machine
docker build -t <tag-name> .
docker run -p 8080:8080 <tag-name>
You must specify publish/expose port 8080 of the container as the Dockerfile defines it as such.
You can always refer to Docker's documentation for more options and guidance.
After the development server has started successfully, visit http://localhost:8080
to visit the application.
We utilise the following tools for testing:
Cypress
as the test runner that includes assertions, mocking and stubbing.Cucumber
as the spec/test files through Domain-Specific Language (DSL) with the Gherkin syntaxs.
The cucumber tests depend on two things for it to run properly:
- The rails development server started with a cleared, seeded database
# assuming you are currently in the "client" directory
cd ..
cd server
rake db:drop
rake db:create
rake db:migrate
rake db:seed
bin/rails server
More information on starting the rails server can be found here
- This client application started in testing mode, and it is recommended to use the npm script below instead of the Dockerfile
npm run start:test
After you have ran the past two todos, you can run either one of the following commands to start cypress.
// e2e testing HEADLESS (i.e. within your terminal)
npm run cypress:run
// e2e testing with GUI
npm run cypress:open
In general, you should have 2-3 active terminals running each doing the following:
- Rails local server at port 5000
- App local server at port 3000
- Cypress runner (if you run it with the GUI i.e.
npm run cypress:open
)