This directory contains tests for the Email Agent application. The tests are organized by feature and use Jest as the testing framework.
email-summarizer.test.js: Tests for the email summarization functionalityprocess-summaries-api.test.js: Tests for the process-summaries API endpointrun-tests.js: A custom test runner script that runs all tests
You can run the tests using the following npm scripts:
# Run all tests
npm test
# Run tests in watch mode (automatically re-run when files change)
npm run test:watch
# Run only the API tests
npm run test:api
# Run only the email summarizer tests
npm run test:summarizerThe tests are designed to be resilient to different environments:
- If running in a CI environment without API keys, the OpenAI API tests will be skipped
- If the server is not running, the API tests will be skipped
- Tests have appropriate timeouts for API calls
To add a new test file:
- Create a new file in the
testsdirectory with the.test.jsextension - Use the Jest testing framework (
describe,test,expect, etc.) - Run the tests to make sure they work
- Keep tests focused on a single feature or component
- Use descriptive test names that explain what is being tested
- Mock external dependencies when possible
- Handle API keys and other secrets securely
- Add appropriate error handling and skipping logic for different environments