From 6636e1c5b842ea73bda3128d6f519c22e3edc592 Mon Sep 17 00:00:00 2001 From: Josh Mu Date: Fri, 27 Dec 2024 14:30:23 +1100 Subject: [PATCH] docs(CONTRIBUTING): add testing guidelines and example structure - Introduced a new section on running tests using Mocha, detailing commands for executing the test suite and specific test files. - Provided guidelines for writing tests, including file placement, naming conventions, and best practices for structuring tests. - Included an example test structure to illustrate the recommended approach for organizing test cases. These additions enhance the documentation for contributors, ensuring clarity on testing practices and improving overall project maintainability. --- CONTRIBUTING.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f44eb6..b066c1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,6 +21,34 @@ To get started with contributing, please follow these steps: 5. Commit your changes and push them to your forked repository. 6. Open a pull request to the main repository. +### Running Tests + +The project uses Mocha for testing. To run the test suite: + +1. Run all tests: `npm test` +2. Run specific test file: `npm test -- path/to/test` + +When writing tests: + +- Place test files in `src/test/suite/` +- Use the naming convention `*.test.ts` +- Group related tests using `suite()` and `test()` +- Keep tests focused and simple +- Mock external dependencies +- Use descriptive test names that explain the expected behavior + +Example test structure: + +```typescript +suite('Feature Name', () => { + test('should handle specific case', async () => { + // Arrange + // Act + // Assert + }); +}); +``` + ### Running the extension Open the extension project in VS Code (e.g. by running `code .` in the project folder).