Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driver-adapter-wasm): add d1-vitest suite #5140

Merged
merged 9 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ jobs:
- d1-cf-basic
- d1-cfpages-basic
- d1-cfpages-nuxt
- d1-vitest
clientEngine: ['wasm']
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions driver-adapters-wasm/d1-vitest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.wrangler
6 changes: 6 additions & 0 deletions driver-adapters-wasm/d1-vitest/.ignore-custom-output
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Prisma Client + Vitest doesn't currently work with a custom output:

```
Error: `require()` is not yet implemented in Workers.
Attempted to `require("./runtime/wasm.js")` from "file:///home/runner/work/ecosystem-tests/ecosystem-tests/driver-adapters-wasm/d1-vitest/prisma/client/wasm.js"
```
22 changes: 22 additions & 0 deletions driver-adapters-wasm/d1-vitest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Prisma Driver Adapters + Vitest

This is a Vitest project that demonstrates how to use Prisma with Driver Adapters.
This project uses:
- Vitest as the test framework
- Cloudflare D1 as a database

Look at the [Cloudflare's Vitest integration documentation](https://developers.cloudflare.com/workers/testing/vitest-integration/) to learn more.

## Setup

Make sure to install the dependencies:

```bash
pnpm install
```

Create a local Cloudflare D1 database:

```bash
pnpm wrangler d1 migrations apply d1-vitest --local
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL
);
25 changes: 25 additions & 0 deletions driver-adapters-wasm/d1-vitest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "prisma-vitest-miniflare",
"version": "1.0.0",
"type": "module",
"author": {
"name": "Alberto Schiabel",
"email": "[email protected]"
},
"scripts": {
"test": "vitest --run"
},
"license": "MIT",
"dependencies": {
"@prisma/adapter-d1": "5.16.0-dev.63",
"@prisma/client": "5.16.0-dev.63"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "0.4.5",
"@cloudflare/workers-types": "4.20240614.0",
"prisma": "5.16.0-dev.63",
"typescript": "^5.5.0",
"vitest": "1.5.0",
"wrangler": "3.61.0"
}
}
Loading
Loading