Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
41 changes: 41 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Testing Guide

This project uses Jest for unit testing.

## Running Tests

```bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm test -- --coverage
```

## Test Structure

- Tests are located alongside source files with `.test.ts` extension
- Uses Jest with TypeScript support via `ts-jest`
- Mocks external dependencies like `@inngest/agent-kit`

## Test Coverage

The test suite covers:
- Function configuration and setup
- Agent creation and configuration
- Happy path execution scenarios
- Edge cases and error handling
- Response format validation
- Concurrency and performance
- Integration scenarios
- Real-world usage patterns

## Testing Framework

- **Framework**: Jest 29.7.0
- **Environment**: Node.js
- **TypeScript**: Supported via ts-jest
- **Mocking**: Jest built-in mocking capabilities
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/*.(test|spec).+(ts|tsx|js)'
],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest'
},
moduleNameMapping: {
'^@/(.*)$': '<rootDir>/src/$1'
},
setupFilesAfterEnv: [],
clearMocks: true,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.{ts,tsx}',
'!src/**/*.spec.{ts,tsx}'
]
};
32 changes: 32 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import '@testing-library/jest-dom'

// Mock IntersectionObserver
global.IntersectionObserver = class IntersectionObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}

// Mock ResizeObserver
global.ResizeObserver = class ResizeObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}

// Mock matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"test": "jest",
"test:watch": "jest --watch"
},
"dependencies": {
"@inngest/agent-kit": "^0.9.0",
Expand Down Expand Up @@ -34,13 +36,17 @@
"devDependencies": {
"@eslint/eslintrc": "^3",
"@tailwindcss/postcss": "^4",
"@types/jest": "^29.5.0",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.4.4",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"prisma": "^6.12.0",
"tailwindcss": "^4",
"ts-jest": "^29.1.0",
"tsx": "^4.20.3",
"tw-animate-css": "^1.3.6",
"typescript": "^5"
Expand Down
8 changes: 8 additions & 0 deletions package.json.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Installing testing dependencies if not present
# The following test dependencies are needed:
# @testing-library/react
# @testing-library/jest-dom
# @testing-library/user-event
# jest
# jest-environment-jsdom
# @types/jest
Loading