finished logger tests
This commit is contained in:
parent
68592619f9
commit
d0bc9cf32f
10 changed files with 1178 additions and 16 deletions
65
docs/testing-with-bun.md
Normal file
65
docs/testing-with-bun.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# Testing with Bun in Stock Bot Platform
|
||||
|
||||
This project uses [Bun Test](https://bun.sh/docs/cli/test) for all testing needs. Bun Test provides a fast, modern testing experience with Jest-like API compatibility.
|
||||
|
||||
## Getting Started
|
||||
|
||||
To run tests:
|
||||
|
||||
```bash
|
||||
# Run all tests (using Turbo)
|
||||
bun test
|
||||
|
||||
# Run tests in watch mode
|
||||
bun test:watch
|
||||
|
||||
# Run tests with coverage
|
||||
bun test:coverage
|
||||
|
||||
# Run specific test types
|
||||
bun test:unit
|
||||
bun test:integration
|
||||
bun test:e2e
|
||||
```
|
||||
|
||||
## Library-specific Testing
|
||||
|
||||
Each library has its own testing configuration in a `bunfig.toml` file. This allows for library-specific test settings while maintaining consistent patterns across the codebase.
|
||||
|
||||
### Example bunfig.toml:
|
||||
|
||||
```toml
|
||||
[test]
|
||||
preload = ["./test/setup.ts"]
|
||||
timeout = 5000
|
||||
|
||||
[test.env]
|
||||
NODE_ENV = "test"
|
||||
|
||||
[bun]
|
||||
paths = {
|
||||
"@/*" = ["./src/*"]
|
||||
}
|
||||
```
|
||||
|
||||
## Migration from Jest
|
||||
|
||||
This project has been fully migrated from Jest to Bun Test. Some key differences:
|
||||
|
||||
1. **Import statements**: Use `import { describe, it, expect } from 'bun:test'` instead of Jest imports
|
||||
2. **Mocking**: Use Bun's built-in mocking utilities (see global `spyOn` helper)
|
||||
3. **Configuration**: Use `bunfig.toml` instead of Jest config files
|
||||
4. **Test helpers**: Test helpers are available globally via `global.testHelpers`
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use `describe` and `it` for test organization
|
||||
- Use relative imports (`../src/`) in test files
|
||||
- Keep test setup clean with proper `beforeEach` and `afterEach` handlers
|
||||
- For complex test scenarios, create dedicated setup files
|
||||
|
||||
## Test Environment
|
||||
|
||||
- All tests run with `NODE_ENV=test`
|
||||
- Console output is silenced by default (restore with `testHelpers.restoreConsole()`)
|
||||
- Default timeout is 30 seconds for integration tests, 5 seconds for unit tests
|
||||
Loading…
Add table
Add a link
Reference in a new issue