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

vitest update #254

Merged
merged 10 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 3 additions & 3 deletions packages/app/api-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"@lokalise/eslint-config": "latest",
"@lokalise/prettier-config": "latest",
"@lokalise/package-vite-config": "latest",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "3.3.3",
"rimraf": "^5.0.5",
"typescript": "5.5.4",
"typescript": "5.5.3",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
5 changes: 2 additions & 3 deletions packages/app/backend-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
"@biomejs/biome": "^1.8.3",
"@lokalise/biome-config": "^1.0.0",
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.0.1",
"auto-changelog": "^2.4.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

auto-changelog is not used

"@vitest/coverage-v8": "^2.0.4",
"typescript": "^5.5.4",
"vitest": "^2.0.1"
"vitest": "^2.0.4"
}
}
4 changes: 2 additions & 2 deletions packages/app/context-fastify-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@types/node": "^22.0.0",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@vitest/coverage-v8": "1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vitest": "0.4.1",
Expand All @@ -66,7 +66,7 @@
"prettier": "^3.3.3",
"rimraf": "^5.0.1",
"typescript": "^5.5.4",
"vitest": "1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ErrorReport } from '@lokalise/error-utils'
import { isInternalError } from '@lokalise/node-core'
import fastify from 'fastify'
import type { RouteHandlerMethod } from 'fastify/types/route'
import { beforeEach } from 'vitest'
Expand Down Expand Up @@ -37,26 +38,26 @@ async function initApp(routeHandler: RouteHandlerMethod) {
handler: routeHandler,
})
await app.ready()

return app
}

// This needs to be skipped in CI, because vitest fails the run if there are any unhandled errors. See https://github.com/vitest-dev/vitest/issues/5796
describe.skip('unhandledExceptionPlugin', () => {
describe('unhandledExceptionPlugin', () => {
beforeEach(() => {
errors.splice(0, errors.length)
})

it('handled unhandled rejection', async () => {
it('handled unhandled rejection with Error type', async () => {
const app = await initApp((req, res) => {
void new Promise(() => {
throw new Error('new unhandled error')
throw new Error('new test unhandled error')
})
return res.status(204).send()
})
const response = await app.inject().get('/').end()
expect(response.statusCode).toBe(204)

const errorsReported = await vitest.waitUntil(
await vitest.waitUntil(
() => {
return errors.length > 0
},
Expand All @@ -66,6 +67,38 @@ describe.skip('unhandledExceptionPlugin', () => {
},
)

expect(errorsReported).toBe(true)
expect(errors).toHaveLength(1)
const error = errors[0]
expect(error.error.message).toBe('new test unhandled error')
})

it('handled unhandled rejection with not error type', async () => {
const app = await initApp((req, res) => {
void new Promise(() => {
throw 'this is my test unhandled error'
})
return res.status(204).send()
})
const response = await app.inject().get('/').end()
expect(response.statusCode).toBe(204)

await vitest.waitUntil(
() => {
return errors.length > 0
},
{
interval: 50,
timeout: 2000,
},
)

expect(errors).toHaveLength(1)
const error = errors[0]
expect(isInternalError(error.error)).toBe(true)
expect(error.error).toMatchObject({
errorCode: 'UNHANDLED_REJECTION',
message: 'Unhandled rejection',
details: { errorObject: '"this is my test unhandled error"' },
})
})
})
4 changes: 2 additions & 2 deletions packages/app/error-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"@lokalise/node-core": "^11.2.0",
"@lokalise/prettier-config": "latest",
"@lokalise/package-vite-config": "latest",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "^3.3.3",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/app/events-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"@lokalise/prettier-config": "latest",
"@lokalise/package-vite-config": "latest",
"@message-queue-toolkit/sns": "^17.0.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "3.3.3",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
26 changes: 13 additions & 13 deletions packages/app/events-common/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import packageJson from './package.json'

/* eslint-disable import/no-default-export */
export default defineConfig({
entry: resolve(__dirname, 'src/index.ts'),
dependencies: Object.keys(packageJson.peerDependencies),
test: {
coverage: {
exclude: ['src/**/*.spec.ts', 'src/**/*.test.ts', 'src/**/*Types.ts', 'src/**/*types.ts'],
thresholds: {
lines: 96,
functions: 0, // not applicable
branches: 0, // not applicable
statements: 96,
},
},
},
entry: resolve(__dirname, 'src/index.ts'),
dependencies: Object.keys(packageJson.peerDependencies),
test: {
coverage: {
exclude: ['src/**/index.ts', 'src/**/*.spec.ts', 'src/**/*.test.ts', 'src/**/*types.ts'],
thresholds: {
lines: 96,
functions: 0, // not applicable
branches: 0, // not applicable
statements: 96,
},
},
},
})
4 changes: 2 additions & 2 deletions packages/app/id-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"@lokalise/eslint-config": "latest",
"@lokalise/package-vite-config": "latest",
"@lokalise/prettier-config": "latest",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "^3.3.3",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/app/non-translatable-markup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"@lokalise/eslint-config": "latest",
"@lokalise/prettier-config": "latest",
"@lokalise/package-vite-config": "latest",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "3.3.3",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/app/prisma-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"@lokalise/biome-config": "*",
"@lokalise/package-vite-config": "*",
"@prisma/client": "^5.14.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"cross-env": "^7.0.3",
"dotenv-cli": "^7.4.1",
"prisma": "^5.14.0",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
}
}
5 changes: 3 additions & 2 deletions packages/app/prisma-utils/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
exclude: [
'src/index.ts',
'src/types.ts'
'src/**/index.ts',
'src/**/types.ts',
'src/**/*.spec.ts'
],
reporter: ['text'],
all: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/app/script-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"@lokalise/eslint-config": "latest",
"@lokalise/package-vite-config": "latest",
"@lokalise/prettier-config": "latest",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "^3.3.3",
"rimraf": "^5.0.7",
"typescript": "5.5.4",
"vite": "5.3.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/app/supported-languages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"@lokalise/prettier-config": "latest",
"@lokalise/node-core": "^11.2.0",
"@rollup/plugin-typescript": "^11.1.3",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.4",
"prettier": "^3.3.3",
"rimraf": "^5.0.7",
"rollup": "^4.4.1",
"typescript": "5.5.4",
"vitest": "^1.6.0"
"vitest": "^2.0.4"
},
"prettier": "@lokalise/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/app/universal-ts-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"@biomejs/biome": "^1.8.3",
"@lokalise/biome-config": "^1.0.0",
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.0.1",
"@vitest/coverage-v8": "^2.0.4",
"auto-changelog": "^2.4.0",
"typescript": "^5.5.4",
"vitest": "^2.0.1"
"vitest": "^2.0.4"
}
}
2 changes: 1 addition & 1 deletion packages/app/websockets-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"rimraf": "^5.0.7",
"typescript": "~5.5.4",
"vite": "5.3.4",
"vitest": "1.6.0"
"vitest": "^2.0.4"
},
"dependencies": {
"socket.io": "^4.7.5",
Expand Down
Loading