Skip to content

Files

Latest commit

 

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Testing notes

  • We must test using the esbuild-bundled driver -- the code that's packaged up for npm -- because various shims are inserted only via this process.

  • The reason the serverless driver exists is to enable connecting (and connecting speedily) from a variety of platforms. We therefore test on a variety of platforms. The subfolders here contains these tests.

Platforms

cli

For convenience, the most extensive tests are run via CLI.

In CI we run these tests:

  1. On current Node LTS (Node has top-level fetch from 18, crypto from 19, WebSocket from 22 onwards)
  2. On current Node LTS using vitest's edge-runtime environment
  3. On Node 19, using ws for WebSockets

Currently we run only a few simple tests with Bun, as it is not supported by vitest. The same goes for Deno, for the same reason.

packages

These brief tests make use of the driver from within drizzle-orm and Prisma. In CI, we run them on Node LTS only.

They rely on a file: alias in package.json, from @neondatabase/serverless to the bundled driver.

cloudflare

We run basic local tests on Cloudflare Workers using the wrangler tool's unstable_dev feature.

These tests ensure that the package can be run and a query can be executed via (a) a Client created and connected manually, which uses WebSockets, (b) a Pool, which also uses WebSockets, and (c) the neon function, which uses https fetch.

Note that it will usually be better to use ordinary node-postgres with Cloudflare's Hyperdrive.

vercel

We run the same basic tests in Vercel Functions, and these are actually deployed to and run on Vercel.

Both the nodejs and edge runtimes are tested.

browser

We run similar tests in headless browsers -- Firefox and Chromium -- using vitest's support for playwright.

Extensions

Possible future extensions to testing:

  • Test more scenarios!

  • Run tests on AWS Lambda

  • Run tests with libraries such as Next.js, including on Cloudflare/Vercel