Conversation
- Installed Vitest, @vitest/ui, @vitest/coverage-v8, jsdom, happy-dom, supertest, and mongodb-memory-server as dev dependencies - Added test scripts to package.json: test, test:ui, test:run, test:coverage - Created vitest.config.backend.js for Node.js backend tests - Created vitest.config.frontend.js for jsdom frontend tests - Updated vite.config.js with test configuration and setup files - Updated .gitignore to exclude coverage reports, .env.test, and test artifacts
- Created tests/setup.js for backend test environment with dotenv configuration - Created tests/setup.browser.js for frontend test environment with jsdom setup - Added tests/helpers/mockData.js with mock users and streams data - Added tests/helpers/mockExpress.js with Express req/res/next mock utilities - Set up global test configuration including localStorage and fetch mocks - Exported TEST_JWT_SECRET for consistent JWT testing across test suites
Backend Tests (10 tests): - tests/unit/backend/middleware/auth.test.js - JWT token validation (valid, missing, invalid format, expired) - Role-based authorization (correct role, incorrect role, missing role) - 100% code coverage on auth middleware Frontend Tests (20 tests): - tests/unit/frontend/theme.test.js (8 tests) - localStorage operations (save, retrieve, overwrite, clear) - DOM manipulation (dark class, toggle, icon updates) - tests/unit/frontend/main.test.js (12 tests) - formatViewers() utility function (number formatting) - debounce() helper function - getFilteredStreams() filtering logic (category, subcategory, languages) Total: 30 passing tests across backend and frontend All tests validated with 'npm run test:run'
- Added comprehensive Testing section with guidelines for contributors - Documented test commands (npm test, test:run, test:ui, test:coverage) - Explained test directory structure (backend, frontend, integration, helpers) - Provided example test following AAA pattern (Arrange, Act, Assert) - Fixed typo: 'collsborator' -> 'collaborator' - Emphasized importance of maintaining test coverage for PRs
- Added 'Run Tests' step to execute npm run test:run in CI workflow - Added 'Generate Coverage Report' step with npm run test:coverage - Tests run after linting and formatting checks, before build - Coverage generation continues on error to not block pipeline - Tests will run on all Node.js versions (20, 22, 24) in matrix - Ensures all PRs have passing tests before merge
|
@gbowne1 I’m unable to update the PR's assignes, reviewers and more, this to meet the CONTRIBUTING.md requirements, could you please address that? |
|
That requires clarification. That can only be done by collaborators and maintainers. I will do that. If you wish to be a regular contributor to this project let us know in the appropriate area of the Discussion tab I'll also review your PR |
gbowne1
left a comment
There was a problem hiding this comment.
I checked out this change locally for testing and review for merge
This adds much needed tests to the codestream project
I was able to replicate the expected results from this PR description
Approving this PR for merge pending further review by our collaborators and maintainers
Thanks for the opportunity to review your PR and for your contribution to this project and please feel free to work on this project, help review its bug fixes, report issues with it and or work on any other projects I have here on Github https://github.com/gbowne1
There are open discussions on the Discussion tab here as well
|
I merged a large PR #87 as an Emergency WIP because of CI breakage. package-lock.json needs fixed. (Probably a delete then reinstall or we untracked it and node_modules left local only) Make sure this PR works with the new merges |




This pull request introduces a comprehensive testing setup for both backend and frontend code, using Vitest as the primary testing framework. It adds test scripts, dependencies, configuration files, and example tests, as well as updates documentation to guide contributors on testing practices. The CI workflow is updated to include test execution and coverage reporting.
Testing infrastructure and configuration:
package.jsonand installed related dependencies for coverage, UI, DOM environments, and mocking (vitest,@vitest/ui,@vitest/coverage-v8,happy-dom,jsdom,mongodb-memory-server,supertest). [1] [2]vitest.config.backend.jsandvitest.config.frontend.jsfor separate backend (Node) and frontend (jsdom) test environments, with coverage and setup files specified. [1] [2]vite.config.jsto include a unified test configuration and coverage exclusion rules.Continuous Integration workflow:
.github/workflows/ci.ymlto run tests and generate coverage reports during CI, ensuring test results are part of the build process.Documentation and contributor guidance:
CONTRIBUTING.mdwith a new Testing section, instructions for running tests, maintaining coverage, and test structure/examples.Test utilities and example tests:
tests/setup.js,tests/setup.browser.js) for environment configuration and mocking. [1] [2]tests/helpers/mockData.js,tests/helpers/mockExpress.js). [1] [2]tests/unit/backend/middleware/auth.test.js).tests/unit/frontend/main.test.js,tests/unit/frontend/theme.test.js). [1] [2]Resolves #18