Sometimes links are placed into the README or in logs that we want to make as stable as possible and friendly to read. To achieve both we use short links like pris.ly/foo
. We manage these for Nexus Prisma in the prisma/pris.ly
repo here.
-
You can run tests with
yarn test
-
You can update snapshots with the Jest CLI:
yarn test -u
yarn test --update-snapshots
- More details here https://jestjs.io/docs/snapshot-testing#updating-snapshots
-
We disable
kleur
colors so snapshots do not have them. It would be nice to put the DX of colors into tests but needs some work. Node 12/14 results in different codes, thus different snapshots. See test-mode feature request here: lukeed/kleur#47 (comment). -
E2e tests run against a Heroku Postgres database. Each run of the test e2e test will reset all data in that database. We do not use
docker-compose
because it is not available on the macOS docker images and it is not possible to run Postgres in Windows GitHub actions machines either. Our CI runs against all OS's.
Sometimes it is useful to use a link workflow. This means working on a local checkout of the Nexus Prisma source code, while trying it out in a project as local on your machine. This can be great for feeling out ideas.
Linking with Nexus Prisma is problematic because some modules in the Nexus Prisma source do file path lookups relative to where they are on disk. These lookups expect to be in the project that is using Nexus Prisma. Regular link workflows violate this assumptions.
The solution is to use Yalc.
Definitions:
Nexus Prisma
: Your local checkout of the source code.Project
: Some project that you are trying out your local version of Nexus Prisma on.
One-time:
- Install yalc on your machine
npm -g add yalc
. - Install nodemon on your machine
npm -g add nodemon
.
Usually-one-time:
- In
Project
runyalc add nexus-prisma
.
Every-time:
- In
Nexus Prisma
run the VSCode taskdev:link
. - In
Project
runnodemon --watch '.yalc/**/*' --exec 'yarn -s prisma generate'
With all this in place, the chain reaction goes like this:
- You change
Nexus Prisma
Nexus Prisma
TS in watch mode emits intodist-esm
anddist-cjs
Nexus Prisma
nodemon
reacts to this, runsyalc push
, Yalc emits intoProject
's.yalc
dirProject
nodemon
reacts to this, runsprisma generate
- You try things out with newly generated Nexus Prisma in
Project
!
One issue is being worked out related to bin
and chmod
: wclr/yalc#156
If you change a dependency in Nexus Prisma
while working (especially adding a new one) you will need to remove the node_modules
in Project
and re-install e.g. yarn install
.
- We use
debug
. Enable by setting envarDEBUG=nexus-prisma*
- If you set envar
NP_DEBUG=true
then Nexus Prisma will writedmmf.json
to CWD at generation time.