Thank you for your interest in contributing to Talawa Admin. Regardless of the size of the contribution you make, all contributions are welcome and are appreciated.
If you are new to contributing to open source, please read the Open Source Guides on How to Contribute to Open Source.
Please read the Palisadoes Contributing Guidelines.
For detailed information about testing, linting, formatting, and code coverage, please refer to our comprehensive Testing Guide.
For security guidelines regarding token handling and authentication, please refer to our Security Guidelines.
Testing:
- Run all tests:
pnpm run test - Run specific test:
pnpm run test /path/to/test/file - Run with coverage:
pnpm run test:coverage - Run with sharding:
pnpm run test:shard
Linting and Formatting:
- Fix linting issues:
pnpm run lint:fix - Fix formatting issues:
pnpm run format:fix - Check linting:
pnpm run lint:check - Check formatting:
pnpm run format:check
Cypress E2E Testing:
- See the Cypress Guide for end-to-end testing
For complete documentation including test sharding, code coverage setup, debugging, and git hooks, visit the Testing Guide.
Proper mock isolation is critical for reliable tests and enables parallel test execution (12-shard CI). All test files using mocks MUST include cleanup to prevent mock leakage.
Every test file using vi.fn(), vi.mock(), or vi.spyOn() must include:
describe('YourComponent', () => {
afterEach(() => {
vi.restoreAllMocks(); // or vi.clearAllMocks()
});
// Your tests here
});We enforce mock isolation through multiple layers:
- ESLint (Real-time IDE feedback): Custom rule detects missing cleanup as you code
- Pre-commit Hook: Runs
check-mock-cleanup.shbefore commits - CI Check: GitHub Actions validates all test files
Before committing, you can run:
# Check mock cleanup
pnpm run check-mock-cleanup
# Run ESLint on test files
pnpm run lint:checkMissing cleanup:
// Bad - no cleanup
describe('Test', () => {
it('test', () => {
const mock = vi.fn();
});
});Correct pattern:
// Good - has cleanup
describe('Test', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('test', () => {
const mock = vi.fn();
});
});Window/Timer manipulation without cleanup:
// Bad - modifies global state
it('test', () => {
window.location.href = 'test';
vi.useFakeTimers();
});Correct pattern:
// Good - restores global state
describe('Test', () => {
const originalLocation = window.location;
afterEach(() => {
window.location = originalLocation;
vi.clearAllTimers();
vi.useRealTimers();
});
});- Prevents flaky tests: Tests won't fail randomly or when run in different orders
- Enables parallelization: Our 12-shard CI provides 4x speedup (only possible with isolation)
- Improves reliability: Guarantees tests are independent and reproducible
For comprehensive guidance, see the Testing Guide.
- After making changes you can add them to git locally using
git add <file_name>(to add changes only in a particular file) orgit add .(to add all changes). - After adding the changes you need to commit them using
git commit -m '<commit message>'(look at the commit guidelines below for commit messages). - Once you have successfully commited your changes, you need to push the changes to the forked repo on github using:
git push origin <branch_name>.(Here branch name must be name of the branch you want to push the changes to.) - Now create a pull request to the Talawa-admin repository from your forked repo. Open an issue regarding the same and link your PR to it.
- Ensure the test suite passes, either locally or on CI once a PR has been created.
- Review and address comments on your pull request if requested.