Skip to content

Add package scripts and cli library, enable integration testing #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jaggederest
Copy link

@jaggederest jaggederest commented Jun 16, 2025

A working vscode-test integration test that validates that the module will load and add commands, at least.

NB the pretty_bytes nonsense is a temporary workaround, I won't merge this until I've fixed the actual usage, but I wanted to get a demonstration test going ASAP since right now I can happily make totally breaking changes 🤦

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Enables integration testing and adds dynamic CLI/utility loading support.

  • Adds a placeholder extension test to validate the test pipeline.
  • Implements dynamic ESM imports for pretty-bytes in storage.ts and remote.ts.
  • Updates package.json and introduces .vscode-test.mjs to configure and run integration tests.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test/extension.test.ts Introduces a dummy test suite to verify the test harness
src/storage.ts Adds dynamic import of pretty-bytes in fetchBinary
src/remote.ts Applies dynamic import of pretty-bytes and makes updateStatus async
package.json Adds test:integration, pretest hooks, and new test CLI deps
.vscode-test.mjs Configures VSCode Test CLI for integration test discovery
Comments suppressed due to low confidence (3)

src/test/extension.test.ts:3

  • [nitpick] The suite name 'first test' is generic; consider renaming it to reflect its purpose (e.g., 'Extension activation suite').
suite("first test", () => {

src/storage.ts:127

  • The dynamic import logic in fetchBinary isn't covered by existing tests; consider adding unit tests to verify that pretty-bytes is loaded correctly and used as expected.
// Load ESM module if not already loaded

src/remote.ts:846

  • The new async updateStatus function with dynamic import isn't covered by tests; consider adding integration tests to validate its behavior under different network inputs.
const updateStatus = async (network: {

jaggederest and others added 5 commits June 16, 2025 14:31
- Add test mode detection to bypass Remote SSH extension requirement
- Skip remoteAuthority access in test mode to avoid API proposal errors
- Update test expectations to match actual extension behavior
- Configure vscode-test to enable proposed API for tests
- Add proper command registration verification with timing delay

The extension now gracefully handles test environments where the Remote
SSH extension is not available, allowing integration tests to pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add vitest.config.ts with proper include/exclude patterns
- Exclude src/test/** directory from unit tests (VS Code integration tests)
- Exclude compiled out/** directory from test discovery
- Update tsconfig.json to exclude vitest.config.ts from compilation
- Add .eslintignore to skip linting vitest config
- Update test script to use default Vitest behavior
- Fix .vscodeignore formatting (add missing newline)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jaggederest jaggederest marked this pull request as ready for review June 16, 2025 22:05
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Leaving off an approve until we sort prettyBytes but this is great!

);
throw new Error("Remote SSH extension not found");
}
// In test mode, use regular vscode API
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I wonder if we can avoid the special testing behavior. Maybe we should always try to activate, but if we are unable to get this special API we skip the remote registration (and possibly log a warning)? Similar to what you already have except we always do it, not just in testing.

That would make it nicer for use cases where you have not installed the remote extension yet, for whatever reason, while reducing drift between production and testing.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I suspect this is the kind of behavior we want, so 👍 to logging a warning and handling it gracefully

import prettyBytes from "pretty-bytes";
// Dynamic import for ESM module
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let prettyBytes: any;
Copy link
Member

Choose a reason for hiding this comment

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

I know you said this was temporary, just leaving a note here to acknowledge we need to update this and other references before merge. 😄

import * as assert from "assert";
import * as vscode from "vscode";

suite("Extension Test Suite", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Exciting to have this working!!

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