Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 2, 2025

Closes #[issue number]

Summary

Enhanced the watch command test suite to validate that adapters correctly restart when their main files change. Previously, tests only verified initial adapter startup in watch mode, but didn't validate the core file-watching and restart behavior.

Changes

New Test Infrastructure

Added runCommandWithFileChange() utility function that:

  • Starts the dev-server in watch mode
  • Waits for initial adapter startup
  • Triggers a file change by touching the main adapter file
  • Waits for nodemon to detect the change and restart the adapter
  • Captures all output for validation

Added validateWatchRestartOutput() validation function that verifies:

  • Nodemon restart messages appear in the logs
  • Adapter starts at least twice (initial startup + restart after file change)
  • Adapter lifecycle events occur multiple times (e.g., state changes)

New Test Cases

Added "should restart adapter when main file changes" test for:

  • JavaScript adapters (test/js-adapters.test.js)
  • TypeScript adapters (test/ts-adapters.test.js)
  • Pure TypeScript adapters (test/pure-ts-adapters.test.js)

How It Works

The test follows this sequence:

  1. Start watch mode: Launches dev-server watch command
  2. Wait for initial startup: Monitors logs for adapter startup completion
  3. Trigger file change: Touches the main adapter file after 5 seconds
  4. Detect restart: Nodemon detects the change and restarts the adapter
  5. Validate logs: Confirms adapter terminates and starts again

Example log sequence from a successful test:

2025-10-02 22:31:11.173 - info: test-js.0 (4519) starting. Version 0.0.1
2025-10-02 22:31:12.229 - info: test-js.0 (4519) state test-js.0.testVariable deleted
[File change triggered]
2025-10-02 22:31:41.698 - info: test-js.0 (4519) terminating
[nodemon] starting `node --inspect ...`
2025-10-02 22:31:42.174 - info: test-js.0 (4550) starting. Version 0.0.1
2025-10-02 22:32:12.239 - info: test-js.0 (4550) state test-js.0.testVariable deleted

Testing

Verified with:

npm run test:js  # ✅ All tests pass including new restart test

The implementation is minimal and focused on validating the specific behavior requested: that adapters properly terminate and restart when files change in watch mode.

Original prompt

This section details on the original issue you should resolve

<issue_title>Enhance "watch" command testing to verify that adapter gets restarted</issue_title>
<issue_description>In the watch mode of the dev-server the adapter files (e.g main.js/ts) is monitored for changes. If the file is changed ( maybe even a touch is enough?) and then the adapter to test is restarted.

Enhance the "watch" testing to include and validate this case. The log should show lines that the adapter is "terminating" and then started again.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #525

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Enhance "watch" command testing to verify that adapter gets restarted Add adapter restart validation to watch command tests Oct 2, 2025
@Copilot Copilot AI requested a review from Apollon77 October 2, 2025 22:37
Copilot finished work on behalf of Apollon77 October 2, 2025 22:37
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.

Enhance "watch" command testing to verify that adapter gets restarted
2 participants