microsoft / vscode-test-cli

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

Cannot specify a custom Mocha reporter #55

Closed 50Wliu closed 1 month ago

50Wliu commented 1 month ago

While the option exists to specify a custom reporter (via mocha.reporter), that doesn't work in practice because of the structuredClone on the config object.

If you try, you'll get an error like

DataCloneError: class JunitSpecReporter extends mocha.reporters.Base {
    junitReporter;
    specReporter;
    constructor(run...<omitted>...
} could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at DesktopPlatform.prepare (file:///C:/__w/1/s/node_modules/@vscode/test-cli/out/cli/platform/desktop.mjs:18:22)
    at file:///C:/__w/1/s/node_modules/@vscode/test-cli/out/bin.mjs:53:38
    at Array.map (<anonymous>)
    at prepareConfigs (file:///C:/__w/1/s/node_modules/@vscode/test-cli/out/bin.mjs:51:48)
    at runConfigs (file:///C:/__w/1/s/node_modules/@vscode/test-cli/out/bin.mjs:128:28)
    at main (file:///C:/__w/1/s/node_modules/@vscode/test-cli/out/bin.mjs:34:26)
connor4312 commented 1 month ago

You will need to pass the path to a reporter, not a reporter object, as tests are run in the extension host and not the CLI

50Wliu commented 1 month ago

Oh, awesome! Could this be documented? The typings had me believing otherwise (plus, this worked with the old index + runTest approach). image

Edit: And thanks for the super-fast response :D

connor4312 commented 1 month ago

Ah, yea, I can try and narrow them a bit