**feat(core): enhance logging, storage options, and testing coverage**

- **Core Improvements**:
  - Refactored logging functions into a unified `logger` method for consistent output across the library.
  - Enabled the `forceMemoryStorage` option in `BrainyData` initialization for improved storage flexibility in tests and specific use cases.

- **TensorFlow.js and Environment Updates**:
  - Clarified the dependency structure in `README.md` to emphasize bundled dependencies and remove legacy peer dependency instructions.
  - Simplified and reformatted environment detection logic for better maintainability and readability.

- **Testing Enhancements**:
  - Added `tests/package-size-limit.test.ts` to monitor and validate npm package size against defined thresholds.
  - Updated `tests/environment.node.test.ts` and core tests to leverage `forceMemoryStorage` for better test setup standardization.
  - Improved test isolation with expanded `globalThis` utility definitions and cleanup logic.

- **Documentation**:
  - Added detailed best practices for debugging and organizing tests in `DEVELOPERS.md`.
  - Removed outdated installation hints from `package.json` and streamlined scripts by including `test:size` for package size validation.

**Purpose**: These changes unify core logging mechanisms, expand configurability of storage options, and improve testing reliability and coverage. Documentation and clarity are enhanced to align with updated functionality and best practices.
This commit is contained in:
David Snelling 2025-07-17 10:00:28 -07:00
parent 7878f200fc
commit e12ecf8d72
8 changed files with 238 additions and 39 deletions

View file

@ -62,6 +62,31 @@ Brainy uses a modern build system that optimizes for both Node.js and browser en
## Testing
### Testing Best Practices
When developing and debugging Brainy, follow these testing guidelines:
1. **Use Proper Test Files**: All tests should be written as vitest test files in the `tests/` directory with `.test.ts` or `.spec.ts` extensions.
2. **Avoid Temporary Debug Files**: Do not create temporary debug files like `debug_test.js`, `reproduce_issue.js`, or similar files in the root directory. These files:
- Clutter the repository
- Are excluded by vitest configuration but remain in the codebase
- Often duplicate functionality already covered by proper tests
3. **Debugging Approach**: When debugging issues:
- Add temporary test cases to existing test files in the `tests/` directory
- Use `it.only()` or `describe.only()` to focus on specific tests during debugging
- Remove or convert temporary test cases to permanent tests before committing
- Use the existing test setup and utilities in `tests/setup.ts`
4. **Test Organization**:
- Core functionality tests go in `tests/core.test.ts`
- Environment-specific tests go in `tests/environment.*.test.ts`
- Utility function tests go in `tests/vector-operations.test.ts`
- New feature tests should follow the existing naming convention
5. **Cleanup**: Always clean up temporary files before committing. The vitest configuration already excludes `*.js` files in the root directory, but they should be deleted rather than left in the repository.
### Testing All Environments
Brainy provides a comprehensive test script that verifies the library works correctly in all supported environments (