microsoft / vscode-test-cli

Command-line runner for VS Code tests
MIT License
19 stars 7 forks source link

Bug: Argument Parsing Issues with Config, label, and others params #31

Closed jacobwi closed 4 months ago

jacobwi commented 5 months ago

I'm encountering several issues with argument parsing in vscode-test, specifically with the --label, --config, and potentially other parameters. Below are the commands I tried and the unexpected outcomes I observed:

Issues with --label argument:

vscode-test --label main doesn't work vscode-test -l main doesn't work

Despite having a configuration labeled "main" as shown below, I receive an error stating that a configuration with label "main" could not be found.

import { defineConfig } from '@vscode/test-cli';

export default defineConfig([
  {
    "label": "main",
    files: 'out/test/**/*.test.js', // Pattern to match test files
    version: 'insiders', // Use VS Code Insiders for running tests
    mocha: {
      ui: 'bdd', // Behavior-Driven Development style interface
      timeout: 20000 // Set test timeout to 20 seconds
    }
  }
]);

vscode-test --config .vscode-test.mjs doesn't work vscode-test --config ./.vscode-test.mjs doesn't work vscode-test --config ".vscode-test.mjs" doesn't work vscode-test --config "./.vscode-test.mjs" doesn't work

When attempting to specify the configuration file, various formats of the --config argument lead to failures, either not recognizing the file or not parsing it correctly.

Additional tests: Using the command "test": "vscode-test --config ./.vscode-test.contextmenu.mjs --label main" also resulted in errors, with the following output:

TypeError: Cannot read properties of undefined (reading 'length')
    at [file path on your system]/enhanced-resolve@5.16.0/node_modules/enhanced-resolve/lib/util/path.js:41:12

This error seems to stem from an issue with path handling within the enhanced-resolve package or potentially within vscode-test's usage of it.

Fixed it and will commit shortly.