CivicTechJobs
CivicTechJobs copied to clipboard
Feat/vitest
Fixes #670
Changes
- install vitest and required dependencies
- configured vitest
- migrate old jest tests to vitest
- ~~reinstalled
package-lock.jsonandnode_modules~~ - uninstalled jest and its dependencies
Minor changes:
- added named volume for
node_modulesto docker compose. The vite container wasn't working on windows before, and naming the volume helped to debug it. - ~~installed package
eslint-config-prettierto fix a linter issue, since eslint got updated to version 9.25.1 in the new package-lock.json~~ - ~~linted frontend files - mostly effected changes to tailwind classnames order in some components~~
How it works
First, make sure you have node.js installed on your machine, then run npm install in the /frontend folder. This should install the new dependencies.
In the /frontend folder, run the command:
npm run test
It should say all tests pass, although there are some warnings:
How to test this PR
- [ ] cd into the
/frontendfolder and runnpm install - [x] make sure
npm run testworks. - [ ] please make sure the new npm packages and docker compose works on your machine
- [ ] You might have to reinstall
node_modulesto get it to work:rm -rf node_modules && npm i
This is the error I got when I originally tried to npm install vitest, then run docker:
Error: Cannot find module @rollup/rollup-linux-x64-musl. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
I only got this when I tried to run docker compose up. Not when I was running the vite server on my local machine.
During dev meeting on 04/28, Benny said he tried testing this PR's docker compose up and it didnt work on his machine. He mentioned docker on windows and mac uses different linux binaries under the hood.
Reference links:
- https://stackoverflow.com/questions/78336694/error-cannot-find-module-rollup-rollup-linux-x64-musl-on-docker-container
- https://sandipdulal.medium.com/fixing-vite-build-error-on-linux-and-windows-using-docker-error-cannot-find-module-e73bb2fb479d
- https://github.com/vitejs/vite/discussions/15532
04/30/25 update:
I made a new commit. This time instead of removing node_modules and package-lock.json and reinstalling, I took the package.json and package-lock.json from the develop branch, and used the npm cli to install packages one at a time, testing docker with each new install to make sure the @rollup/rollup-linux-x64-musl missing module error didn't occur again.
For some reason no issues came up this time 🤔
@bennyv8 Could you try testing and reviewing again?