Skip to content

Commit d506fd3

Browse files
author
helicalbytes
committed
Documentation updates
1 parent 7fb3298 commit d506fd3

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

README.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the [issue list](https://github.com/DoESLiverpool/optimism/issues) for what
1111
NOTE: You'll need to be using `npm` version 7 or above for this to work, **and** version 14 or *earlier* of NodeJS because `node-sass` does not support version 16 yet.
1212

1313
1. Install the dependencies `npm install`
14-
1. Set up the database `npx knex migrate:latest` (or if there have been any changes to the database structure, this will run the migrations)
14+
1. Set up the database `npx knex migrate:latest --knexfile ./api/knexfile.js` (or if there have been any changes to the database structure, this will run the migrations)
1515
1. Create a `.env` file in this folder. This will hold any configuration options you need to set. For a basic development setup this should suffice:
1616
````
1717
OPTIMISM_API_PORT = 3001
@@ -20,20 +20,24 @@ NOTE: You'll need to be using `npm` version 7 or above for this to work, **and**
2020
2121
OPTIMISM_ENABLE_DETAILED_ERROR_MESSAGES = 1
2222
````
23-
1. [Optional] Populate the development database with some sample data: `npx knex seed:run --env development` (**WARNING: this will delete any data in the database already**)
23+
1. [Optional] Populate the development database with some sample data: `npx knex seed:run --env development --knexfile ./api/knexfile.js` (**WARNING: this will delete any data in the database already**)
2424
2525
## Script commands
2626
2727
The following commands are defined in package.json:
2828
2929
```javascript
30-
"website": "nodemon --watch website website/app.js",
31-
"api": "nodemon --watch api api/app.js",
32-
"both": "concurrently -n \"website,api\" \"npm run website\" \"npm run api\"",
33-
"css": "sass bootstrap/optimism.scss -o website/static/css",
34-
"css-watch": "sass bootstrap/optimism.scss -o website/static/css -w bootstrap/optimism.scss",
35-
"dev-all": "concurrently -n \"website,api,sass\" \"npm run website\" \"npm run api\" \"npm run css-watch\""
30+
"scripts": {
31+
"test-api": "cross-env NODE_ENV=testing mocha api --recursive --exit --timeout 3500 --require mocha-suppress-logs",
32+
"website": "nodemon --watch website website/app.js",
33+
"api": "nodemon --watch api api/app.js",
34+
"both": "concurrently -n \"website,api\" \"npm run website\" \"npm run api\"",
35+
"css": "sass website/scss/optimism.scss:website/static/css/optimism.css",
36+
"css-watch": "sass website/scss/optimism.scss:website/static/css/optimism.css --watch",
37+
"dev": "concurrently -n \"website,api,sass\" \"npm run website\" \"npm run api\" \"npm run css-watch\""
38+
}
3639
```
40+
`npm run test-api` runs the API tests
3741
3842
`npm run website` starts the website (by running website/app.js)
3943
@@ -45,9 +49,8 @@ The following commands are defined in package.json:
4549
4650
`npm run css-watch` watches optimisim.scss and compiles it if it changes
4751
48-
`npm run dev-all` concurrently starts the website, api and css-watch
52+
`npm run dev` concurrently starts the website, api and css-watch
4953
50-
`npm run test` (or `npm tests` or `npm t`) runs .js files in the test subfolder. You can use one of the existing files e.g. app.test.js as a template (first set the NODE_ENV environment variable to 'testing' and run `npx knex install:latest` to use the latest version of the test database)
5154
5255
The `nodemon` commmand is used to monitor code changes in each of the website and api projects and restart these as required.
5356
@@ -74,3 +77,7 @@ Their interactions are orchestrated with `docker-compose`, so getting it running
7477
To run any database migrations, once things are running then run: `docker-compose exec api npx knex migrate:latest --env production`
7578
7679
Any time things are pushed to the `master` branch, the [live site will automatically deploy the new version](https://github.com/DoESLiverpool/optimism/issues/48).
80+
81+
## Also see
82+
83+
[Testing](./documentation/testing)

documentation/testing.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Testing Optimism
2+
3+
## API tests
4+
5+
These live in the ./api/test folder. To run them, use:
6+
7+
`npm run test-api`
8+
9+
The tests are currently integration tests only. They test the API endpoints against a running instance of the API. This is still a WIP and will eventually test endpoints for correct return values including returning appropriate HTTP response codes on failure.
10+
11+
Unit tests are TODO.
12+
13+
14+
## Website tests
15+
16+
TODO
17+
18+
Still to be finalised but Cypress may be our choice of front-end testing framework. Tests can be run manually or as part of CI/CD.

0 commit comments

Comments
 (0)