Skip to content

Add comprehensive test suite using Node.js built-in test runner#4

Merged
electerious merged 4 commits intomainfrom
copilot/fix-42f3ecf9-b390-4be4-9ca7-497dccdf03d7
Sep 6, 2025
Merged

Add comprehensive test suite using Node.js built-in test runner#4
electerious merged 4 commits intomainfrom
copilot/fix-42f3ecf9-b390-4be4-9ca7-497dccdf03d7

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 5, 2025

This PR implements a complete test suite for the lightroom-controller project using Node.js built-in test runner (node --test) and node:assert/strict as requested.

Changes Made

Test Infrastructure

  • Created tests/ directory containing comprehensive test coverage
  • All tests use node:assert/strict for assertions
  • Tests are automatically discovered and run by the existing npm test script
  • Full compatibility with project's ES modules and coding standards (ESLint + Prettier)

Test Coverage

tests/server.test.js - HTTP Server functionality:

  • Server creation and lifecycle management
  • URL pattern parsing (/parameter/message routes)
  • Parameter handling for increment/decrement operations with optional amounts
  • Error handling (404 for invalid routes, 500 for socket failures)
  • Edge case validation (invalid amount parameters)
  • Uses get-port package to find free ports instead of port 0

tests/socket.test.js - WebSocket functionality:

  • Module structure and export validation
  • Request object structure validation
  • Message type validation (increment, decrement, register, close)
  • Parameter array validation for different operation types

Test Results

  • 11 tests total, all passing
  • ~150 lines of focused test code
  • Zero test failures or linting issues
  • Complete coverage of core functionality

The test suite validates the essential functionality of the Lightroom controller while maintaining minimal scope and following the project's established patterns. Tests use proper mocking to avoid external dependencies and ensure reliable, fast execution.

Usage

npm test  # Runs linting + node --test (existing script)

Recent Updates

  • Remove CLI tests as requested
  • Replace port 0 usage with get-port package for finding free ports

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Node.js tests with strict assertions and update test script in package.json Add comprehensive test suite using Node.js built-in test runner Sep 5, 2025
Copilot AI requested a review from electerious September 5, 2025 14:36
@electerious
Copy link
Copy Markdown
Owner

@copilot Remove tests for the CLI

@electerious
Copy link
Copy Markdown
Owner

@copilot Don't use port 0 in the tests, find a free port with 'get-port' instead

Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 6, 2025

@copilot Remove tests for the CLI

CLI tests have been removed as requested. The test suite now only includes server and socket functionality tests (11 tests total, all passing).

Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 6, 2025

@copilot Don't use port 0 in the tests, find a free port with 'get-port' instead

Replaced all port 0 usage with get-port package in tests. All 6 server tests now use const port = await getPort() to find available ports. Tests pass successfully with the new approach. (39af6b1)

@electerious electerious marked this pull request as ready for review September 6, 2025 14:13
@electerious electerious merged commit 171f976 into main Sep 6, 2025
21 checks passed
@electerious electerious deleted the copilot/fix-42f3ecf9-b390-4be4-9ca7-497dccdf03d7 branch September 6, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants