doougui / douglasgoulart.com

:earth_americas: My personal website with all my infos and where I post about software development.
https://douglasgoulart.com
2 stars 0 forks source link

Creating a complete Node.js test environment with Vitest, PostgreSQL and Prisma | Douglas Pinheiro Goulart #33

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Creating a complete Node.js test environment with Vitest, PostgreSQL and Prisma | Douglas Pinheiro Goulart

Node.js complete test environment using TypeScript, Prisma, PostgreSQL and Vitest.

https://www.douglasgoulart.com/writings/creating-a-complete-nodejs-test-environment-with-vitest-postgresql-and-prisma?utterances=fa9fa6dd28d965170c3d8df6YzFjJa%2BwBuJPr57WA1l77tQBhb%2BlvVlrJuodMgNKTMHkQBmt8%2B2oJkcZNLDmQ4iZwZR4ER6eyGweqORgZm5RFWsuvG7UV0GiBv7zp9751vKF8VUge3%2BFVOBnKD8%3D

vijote commented 1 year ago

Thank you so much for this example! It also helped me to implement a testing environment with linkedom for my frontend app

nguyenduyhung20 commented 1 year ago

Damn, this is an incredible article. I hope you can write another detailed article about Vitest in Node.js, delving deeply into its features, i rarely find a good tutorial on Node, sadly.

thiagoleite92 commented 8 months ago

Thx, friend, you're a friend.

abetoots commented 7 months ago

Thanks for the great article! Question though, I can understand using Vitest for unit tests. Could you provide context as to why we should also use it for E2E? I'm new to testing and when E2E is mentioned you'd hear about Playwright or Puppeteer.

petergoldstein commented 7 months ago

This is very useful, thanks.

A question - What creates the new schema with the random name? Is that created when we run the migrations?

We're having trouble with extensions in the migrations, and I'd like to set up the extensions manually in the schema we're creating. I'd like to do that after the schema is created, but before the migrations run. Any suggestions? Thanks.

anotheri commented 6 months ago

Thanks for the helpful article! Sharing a couple of ideas on how to simplified this setup quite a bit:

  1. since 0.34.0 we "can specify a path to a valid JS/TS file", so no need to create a package for environment really. Also notice: since 0.34.0 Vitest requires transformMode option on environment object, read more;

  2. we can use the workspaces to simplify configuration:

    • one for unit tests (with environment: 'node'),
    • another one for e2e tests (with environment: 'path/to/vitest-environment-prisma-file').