chore: migrate project to Bun testing framework and update configuration

- Replace Jest with Bun's native testing framework
- Update test configuration and utilities to support Bun test environment
- Add mock implementations for SSE and security testing
- Refactor test setup to use Bun's testing utilities
- Update package dependencies and scripts to align with Bun testing
- Enhance type definitions for Bun test mocking
This commit is contained in:
jango-blockchained
2025-02-03 22:19:43 +01:00
parent b7856e9d05
commit a53cec7b28
12 changed files with 403 additions and 175 deletions

View File

@@ -1,76 +1,37 @@
import type { Config } from '@jest/types';
import type { JestConfigWithTsJest } from 'ts-jest';
const config: Config.InitialOptions = {
const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/?(*.)+(spec|test).+(ts|tsx|js)'
],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest'
},
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
'^(\\.{1,2}/.*)\\.js$': '$1',
},
setupFilesAfterEnv: [
'<rootDir>/src/__tests__/setup.ts'
],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
isolatedModules: true
}
},
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/__tests__/**',
'!src/**/__mocks__/**',
'!src/**/types/**'
],
coverageReporters: ['text', 'lcov', 'html'],
coverageDirectory: 'coverage',
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
tsconfig: 'tsconfig.json',
},
],
},
testMatch: ['**/__tests__/**/*.test.ts'],
verbose: true,
testTimeout: 10000,
maxWorkers: '50%',
errorOnDeprecated: true,
clearMocks: true,
resetMocks: true,
restoreMocks: true,
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/.cursor/'
],
watchPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/.cursor/',
'/coverage/'
],
modulePathIgnorePatterns: [
'/dist/',
'/.cursor/'
],
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx',
'json',
'node'
]
testTimeout: 30000,
maxWorkers: '50%',
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov'],
globals: {
'ts-jest': {
useESM: true,
isolatedModules: true,
},
},
};
export default config;