diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 0000000..656583e --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,18 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + roots: ['/tests'], + testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'], + transform: { + '^.+\\.ts$': [ + 'ts-jest', + { + isolatedModules: true + }, + ], + }, + collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts', '!src/**/index.ts', '!src/examples/**'], + coverageDirectory: 'coverage', + coverageReporters: ['text', 'lcov', 'html'], + testTimeout: 30000, +}; diff --git a/jest.config.mjs b/jest.config.mjs deleted file mode 100644 index 200b828..0000000 --- a/jest.config.mjs +++ /dev/null @@ -1,34 +0,0 @@ -export default { - preset: 'ts-jest/presets/default-esm', - extensionsToTreatAsEsm: ['.ts'], - testEnvironment: 'node', - roots: ['/src', '/tests'], - testMatch: [ - '**/__tests__/**/*.ts', - '**/?(*.)+(spec|test).ts' - ], - transform: { - '^.+\\.ts$': ['ts-jest', { - useESM: true - }], - }, - collectCoverageFrom: [ - 'src/**/*.ts', - '!src/**/*.d.ts', - '!src/**/index.ts', - '!src/examples/**', - ], - coverageDirectory: 'coverage', - coverageReporters: [ - 'text', - 'lcov', - 'html' - ], - setupFilesAfterEnv: ['/tests/setup.ts'], - testTimeout: 30000, - moduleNameMapping: { - '^@/(.*)$': '/src/$1', - '^@orbitdb/core$': '/tests/mocks/orbitdb.ts', - '^@helia/helia$': '/tests/mocks/ipfs.ts', - }, -}; \ No newline at end of file diff --git a/package.json b/package.json index d49f2ec..26bb47d 100644 --- a/package.json +++ b/package.json @@ -87,14 +87,5 @@ "tsc-esm-fix": "^3.1.2", "typescript": "^5.8.2", "typescript-eslint": "^8.29.0" - }, - "compilerOptions": { - "typeRoots": [ - "./node_modules/@types", - "./node_modules/@constl/orbit-db-types" - ], - "types": [ - "@constl/orbit-db-types" - ] } } diff --git a/tests/basic.test.ts b/tests/basic.test.ts new file mode 100644 index 0000000..181ae04 --- /dev/null +++ b/tests/basic.test.ts @@ -0,0 +1,22 @@ +import { describe, it, expect } from '@jest/globals'; + +describe('Basic Framework Test', () => { + it('should be able to run tests', () => { + expect(1 + 1).toBe(2); + }); + + it('should validate test infrastructure', () => { + const mockFunction = jest.fn(); + mockFunction('test'); + expect(mockFunction).toHaveBeenCalledWith('test'); + }); + + it('should handle async operations', async () => { + const asyncFunction = async () => { + return Promise.resolve('success'); + }; + + const result = await asyncFunction(); + expect(result).toBe('success'); + }); +}); \ No newline at end of file