npx nuxi analyze
npm run test:unit
# Or with coverage:
npm run test:unit:coverage
First start the test dependencies (Mockoon server and database image):
scripts/run-integration-test-dependencies
Then run:
npm run test:integration
More information about integration test set-up in tests/integration/INTEGRATION_TESTING.md
.
'End-to-end' includes running the R API and its worker(s) in addition to the present application.
- Ensure you have the service dependencies up and running (
./scripts/run-dev-dependencies
), and that the Mockoon server is not running. - Run:
npm run test:e2e
Use Node 20.
Make sure Docker is installed.
Build and run the database container and R API container using this script:
scripts/run-dev-dependencies
If you have trouble with the R API image, there might be helpful information in its own README.
Run the below to copy .env.example
to .env
and then run the dev:init
command, which installs the JS dependencies, runs any pending database migrations, and starts up the server in development mode on http://localhost:3000
:
cp .env.example .env
npm run dev:init
If you've already done 'Your first time setting up', you can quickly get back to work by:
# In one terminal window
scripts/run-dev-dependencies --db-build-skip # Skips the build step for the db container, and tries to run an existing image
Omit the --db-build-skip
flag if you are branching off, so that you build a new image for your new branch.
# In another terminal window
npm run dev
You can also expose the app to your local network, so that you can try it out on a mobile device, using:
npm run dev -- --host
The QR code shown will allow you to quickly access the app.
See the 'production' section of this README for how to run the app in production mode.
There are Dockerfiles for both the web app (in /docker
) and the database (in /db
).
To run the app in docker:
./scripts/run-dev-dependencies
./docker/build
./docker/run-dev
This will build and run the app container, exposing port 3000, so you should be able to access the web app at http://localhost:3000 as you can when running locally outside docker.
To tear down, you'll need to Ctrl+C from the /docker/run-dev
script before the /scripts/run-dev-dependencies
script.
Our ORM is Prisma.
To create migrations to the database, first update the Prisma schema at ./prisma/schema.prisma as required, then run the below command to generate the corresponding SQL migration and to apply it to the database. You should commit both the Prisma schema and the migration file to Git.
npm run db:dev:migrate
The same command is also used to apply migrations that already exist in ./prisma/migrations but which have not been applied to the database.
Prisma ORM can only query the database once you 'generate' the Prisma Client, which generates into node_modules/.prisma/client
based on the file prisma/schema.prisma
. This should happen when you install the JS dependencies and whenever you run a migration, but if the Prisma client gets out of sync or doesn't generate, you can manually generate it:
npx prisma generate
More helpful information about Prisma development workflows and resolving issues in production environments.
In VSCode, you can use the extension with ID 'Prisma.prisma' to get syntax highlighting etc.
Linting and formatting are handled jointly by @nuxt/eslint (an "all-in-one" ESLint "integration" for Nuxt) and by the more frequently-updated, conventionally- and widely-used @antfu/eslint-config (antfu works at NuxtLabs, and the package is given as an example in the @nuxt/eslint
docs). The former handles linting only, while the latter also handles formatting, based on ESLint Stylistic.
You should install the lint-fixing commit hook (which will apply to this repo only) using:
npx simple-git-hooks
This will help us keep git history tidy, avoiding clogging up git blame
s with linting-only commits.
This is a helpful tool for inspecting your config setup, so you can check which rules are applied, in which order:
npx @eslint/config-inspector
In VSCode, make sure your ESlint VS Code extension (vscode-eslint) is at least v3.0.10 (released June 2024). Turn on the 'Format on Save' setting.
To document why some of package.json is the way it is (since JSON doesn't support comments):
@rollup/rollup-linux-x64-gnu
is an optional dependency as a fix for the issue that Rollup describes here and which occurred for us when doing an installation with npm on Docker on CI. Their suggested fix does not work for our use case, because removing package-lock.json prevents the use ofnpm ci
, so instead we use the solution suggested here.
Playwright tests produce HTML reports when they run, whether on CI or not, showing visual snapshots at each timestep in each test. If you need to open these, follow the instructions here, particularly 'Viewing the HTML report'.
Build the Nuxt application for production:
npm run build
Locally preview production build:
npm run preview
Check out the deployment documentation for more information.