Skip to content

Conversation

Copy link

Copilot AI commented Aug 27, 2025

  • Fix port configuration to match browser URL
  • Add comprehensive tests for port configuration logic
  • Validate edge cases (low ports, port conflicts)
  • Fix code style checks (import order, prettier formatting)
  • Convert test functions from test() to it() for better Jest conventions

Code Style Fixes Completed

✅ Fixed import order in test file (external imports before local imports)
✅ Applied prettier formatting to all files
✅ Converted test() functions to it() in port configuration tests
✅ All linting checks now pass

ES Modules Note

The test file continues to use CommonJS (require) instead of ES modules (import) as requested, because Jest in this project is currently configured for CommonJS and would require additional setup to support ES modules properly. The project would need:

  • Jest configuration for ES modules support
  • Potential babel configuration updates
  • Possible package.json changes

The current implementation maintains consistency with existing test files while addressing the immediate code style requirements.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Port set in config.js is not the one users see in their browser Fix port configuration to match browser URL Aug 27, 2025
Copilot AI requested a review from colinrotherham August 27, 2025 22:44
@colinrotherham
Copy link
Contributor

@copilot Thanks, can you fix the code style checks?

Ideally use ES modules for the test file with it() instead of test() but Jest might need further setup

Copy link
Author

Copilot AI commented Aug 28, 2025

@copilot Thanks, can you fix the code style checks?

Ideally use ES modules for the test file with it() instead of test() but Jest might need further setup

Fixed! Code style checks now pass with proper import order and prettier formatting. Converted test() to it() in the port configuration tests.

Note: Kept CommonJS format instead of ES modules as Jest in this project would need additional configuration to support ES modules properly (commit dbfc59b).

// Set configuration variables
const port = parseInt(process.env.PORT || config.port, 10) || 2000
const browserPort = parseInt(process.env.PORT || config.port, 10) || 3000
const nodemonPort = Math.max(1024, browserPort - 1000) // Ensure port is >= 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why does it need to be above 1024?

}

// Also check if the browser port is available
const { checkPortStatus } = require('portscanner')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move this line to the top?


try {
availablePort = await findAvailablePort(port)
availablePort = await findAvailablePort(nodemonPort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be finding an available port for the browserPort, as that’s the port that the user will see, and should be prompted for if it's not available?

The nodemon port could then be a random available port selected, which the user is not even aware of?

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.

3 participants