|
| 1 | +# Copilot Instructions for mentoss |
| 2 | + |
| 3 | +## Project structure |
| 4 | + |
| 5 | +- `src/` - Source code for the project. |
| 6 | +- `tests/` - Unit tests for the project. |
| 7 | + - Test files are named to match the source files they test, with a `.test.js` suffix. |
| 8 | +- `docs/` - Documentation for the project. |
| 9 | + |
| 10 | +## Key Implementation Details |
| 11 | + |
| 12 | +- The `MockServer` class provides helpers for route matching, request/response tracing, and test assertions. |
| 13 | +- The `traceCalled(request)` method returns an object: `{ traces: Array<Trace>, matched: boolean }`. |
| 14 | + - If a called route matches, it immediately returns `{ traces: [], matched: true }`. |
| 15 | + - If no called route matches, it collects trace info from both called and unmatched routes and returns `{ traces, matched: false }`. |
| 16 | +- The `called(request)` method uses `traceCalled` and: |
| 17 | + - Returns `true` if a called route matches. |
| 18 | + - Returns `false` if no called route matches but traces exist. |
| 19 | + - Throws an error with the message `"This request pattern doesn't match any registered routes."` if both `matched` is `false` and `traces` is an empty array. |
| 20 | +- The error message for unmatched patterns is standardized for consistency in code and tests. |
| 21 | +- Tests for `traceCalled` and `called` expect the above behaviors and error messages. |
| 22 | + |
| 23 | +## Documentation |
| 24 | + |
| 25 | +- Changes to the public API must be documented in the `docs/` directory. |
| 26 | +- Documentation should be clear and concise, explaining the purpose and usage of each public method. |
| 27 | +- Use examples to illustrate usage where appropriate. |
| 28 | + |
| 29 | +## Testing/Validation |
| 30 | + |
| 31 | +- Never remove failing tests. |
| 32 | +- Always add new tests for any new functionality or changes to existing functionality. |
| 33 | +- When modifying existing tests, ensure they still validate the intended behavior. |
| 34 | +- When adding new tests, ensure they cover all edge cases and expected behaviors. |
| 35 | +- Tests should be clear and concise, focusing on the specific functionality being tested. |
| 36 | +- Use descriptive names for test cases to indicate what functionality is being tested. |
| 37 | +- All tests must pass for changes to be considered complete. |
| 38 | +- Use `npm test` to run all tests and ensure they pass before submitting changes. |
| 39 | +- Use `npx mocha <filename>` to run a specific test file if needed. |
| 40 | +- Do not `cd` into the project directory; run commands from the current working directory. |
| 41 | + |
| 42 | +## General Guidance |
| 43 | + |
| 44 | +- When making changes to route matching, tracing, or test helpers, update both implementation and tests to keep them in sync. |
| 45 | +- Always keep error messages and return value structures consistent between code and tests. |
0 commit comments