Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions packages/app/fastify-api-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"scripts": {
"build": "rimraf dist && tsc --project tsconfig.build.json",
"dev": "vite watch",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is the purpose of this, but if you think it is useful please let me know and I will revert this change 🙏

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not

"lint": "biome check . && tsc --project tsconfig.json --noEmit",
"lint:fix": "biome check --write",
"test:ci": "vitest run --coverage",
Expand All @@ -35,7 +34,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@lokalise/biome-config": "^1.5.0",
"@lokalise/package-vite-config": "latest",
"@lokalise/tsconfig": "^1.0.2",
"@lokalise/universal-ts-utils": "^4.2.1",
"@vitest/coverage-v8": "^3.0.7",
"fastify-type-provider-zod": "^4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('fastifyApiContracts', () => {
})

it('uses API spec to build valid DELETE route with header in fastify app', async () => {
expect.assertions(2)
expect.assertions(4)
const contract = buildDeleteRoute({
successResponseBodySchema: BODY_SCHEMA,
requestPathParamsSchema: PATH_PARAMS_SCHEMA,
Expand All @@ -161,12 +161,21 @@ describe('fastifyApiContracts', () => {
})

const app = await initApp(route)
// using headers directly
const response = await injectDelete(app, contract, {
headers: { authorization: 'dummy' },
pathParams: { userId: '1' },
})

expect(response.statusCode).toBe(200)

// using headers factory
const response2 = await injectDelete(app, contract, {
headers: () => Promise.resolve({ authorization: 'dummy' }),
pathParams: { userId: '1' },
})

expect(response2.statusCode).toBe(200)
})
})

Expand Down Expand Up @@ -319,7 +328,7 @@ describe('fastifyApiContracts', () => {
})

it('uses API spec to build valid PUT route with header in fastify app', async () => {
expect.assertions(4)
expect.assertions(8)
const contract = buildPayloadRoute({
method: 'put',
requestBodySchema: REQUEST_BODY_SCHEMA,
Expand All @@ -337,13 +346,23 @@ describe('fastifyApiContracts', () => {
})

const app = await initApp(route)
// using headers directly
const response = await injectPut(app, contract, {
headers: { authorization: 'dummy' },
pathParams: { userId: '1' },
body: { id: '2' },
})

expect(response.statusCode).toBe(200)

// using headers factory
const response2 = await injectPut(app, contract, {
headers: () => Promise.resolve({ authorization: 'dummy' }),
pathParams: { userId: '1' },
body: { id: '2' },
})

expect(response2.statusCode).toBe(200)
})

it('supports isNonJSONResponseExpected and isEmptyResponseExpected parameters', async () => {
Expand Down
24 changes: 1 addition & 23 deletions packages/app/fastify-api-contracts/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "ESNext",
"moduleResolution": "Bundler",
"target": "ES2022",
"lib": ["ES2022", "dom"],
"sourceMap": false,
"declaration": true,
"declarationMap": false,
"types": ["vitest/globals"],
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"strictNullChecks": true,
"importHelpers": true,
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"extends": ["./tsconfig.json", "@lokalise/tsconfig/build-public-lib"],
"include": ["src/**/*"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
}
5 changes: 2 additions & 3 deletions packages/app/fastify-api-contracts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": ["./tsconfig.build.json"],
"include": ["src/**/*", "vite.config.ts"],
"exclude": []
"extends": "@lokalise/tsconfig/tsc",
"include": ["src/**/*", "vitest.config.ts"]
}
24 changes: 24 additions & 0 deletions packages/app/fastify-api-contracts/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vitest/config'

// biome-ignore lint/style/noDefaultExport: vite expects default export
export default defineConfig({
test: {
globals: true,
watch: false,
environment: 'node',
reporters: ['verbose'],
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
exclude: ['src/**/*.spec.ts', 'src/index.ts'],
reporter: ['text'],
all: true,
thresholds: {
lines: 100,
functions: 100,
branches: 100,
statements: 100,
},
},
},
})
Loading