mirror of
https://github.com/michivonah/themepark-assistant.git
synced 2025-12-22 22:16:29 +01:00
install vitest #3
This commit is contained in:
parent
1729766d06
commit
43580e1036
10 changed files with 2199 additions and 119 deletions
1150
api/package-lock.json
generated
1150
api/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,8 @@
|
|||
"scripts": {
|
||||
"dev": "wrangler dev",
|
||||
"deploy": "wrangler deploy --minify",
|
||||
"cf-typegen": "wrangler types --env-interface CloudflareBindings"
|
||||
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
||||
"test": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/core": "^0.40.0",
|
||||
|
|
@ -16,9 +17,11 @@
|
|||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vitest-pool-workers": "^0.10.3",
|
||||
"@types/node": "^24.3.1",
|
||||
"drizzle-kit": "^0.31.4",
|
||||
"tsx": "^4.20.5",
|
||||
"vitest": "~3.2.0",
|
||||
"wrangler": "^4.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,3 +43,8 @@ export default {
|
|||
fetch: app.fetch,
|
||||
scheduled: cronRouter,
|
||||
}
|
||||
|
||||
// for testing with vitest
|
||||
export {
|
||||
app
|
||||
}
|
||||
4
api/tests/env.d.ts
vendored
Normal file
4
api/tests/env.d.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
declare module "cloudflare:test" {
|
||||
// ProvidedEnv controls the type of `import("cloudflare:test").env`
|
||||
interface ProvidedEnv extends Env {}
|
||||
}
|
||||
41
api/tests/index.test.ts
Normal file
41
api/tests/index.test.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { env } from 'cloudflare:test'
|
||||
import { app } from '../src/index'
|
||||
|
||||
// describe('Example', () => {
|
||||
// it('Should return 200 response', async () => {
|
||||
// const res = await app.request('/hello', {}, env)
|
||||
|
||||
// expect(res.status).toBe(200)
|
||||
// expect(await res.json()).toEqual({
|
||||
// hello: 'world',
|
||||
// var: 'my variable',
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
|
||||
|
||||
|
||||
describe('Authentication', () => {
|
||||
it('Should return 200 response', async () => {
|
||||
const res = await app.request('/themepark/list', {
|
||||
headers: {
|
||||
Cookie: `authjs.session-token=${env.SESSION_TOKEN}`
|
||||
}
|
||||
}, env)
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
// expect(await res.json()).toEqual({
|
||||
// hello: 'world',
|
||||
// var: 'my variable',
|
||||
// })
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// describe('Example', () => {
|
||||
// it('Should return 200 response', async () => {
|
||||
// const res = await app.request('/protected', {}, env)
|
||||
|
||||
// expect(res.status).toBe(200)
|
||||
// })
|
||||
// })
|
||||
14
api/tests/tsconfig.json
Normal file
14
api/tests/tsconfig.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "bundler",
|
||||
"types": [
|
||||
"@cloudflare/vitest-pool-workers", // provides `cloudflare:test` types
|
||||
"vitest/globals"
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"./**/*.ts",
|
||||
"../worker-configuration.d.ts", // output of `wrangler types`
|
||||
],
|
||||
}
|
||||
6
api/tests/vitest.setup.ts
Normal file
6
api/tests/vitest.setup.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { config } from 'dotenv'
|
||||
import { env } from 'cloudflare:test'
|
||||
|
||||
config()
|
||||
|
||||
Object.assign(env, process.env)
|
||||
13
api/vitest.config.ts
Normal file
13
api/vitest.config.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
|
||||
|
||||
export default defineWorkersConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
// setupFiles: ['./tests/vitest.setup.ts'],
|
||||
poolOptions: {
|
||||
workers: {
|
||||
wrangler: { configPath: "./wrangler.jsonc" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
1074
api/worker-configuration.d.ts
vendored
1074
api/worker-configuration.d.ts
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -3,9 +3,9 @@
|
|||
"name": "themepark-assistant",
|
||||
"main": "src/index.ts",
|
||||
"compatibility_date": "2025-09-07",
|
||||
// "compatibility_flags": [
|
||||
// "nodejs_compat"
|
||||
// ],
|
||||
"compatibility_flags": [
|
||||
"nodejs_compat"
|
||||
],
|
||||
// "vars": {
|
||||
// "MY_VAR": "my-variable"
|
||||
// },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue