Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -1343,15 +1343,19 @@ describe("bin/eslint.js", () => {
describe("MCP server", () => {
it("should start the MCP server when the --mcp flag is used", done => {
const child = runESLint(["--mcp"]);
let doneCalled = false;

// should not have anything on std out
child.stdout.on("data", data => {
assert.fail(`Unexpected stdout data: ${data}`);
});

child.stderr.on("data", data => {
assert.match(data.toString(), /@eslint\/mcp/u);
done();
if (!doneCalled) {
assert.match(data.toString(), /@eslint\/mcp/u);
doneCalled = true;
done();
}
Comment on lines 1348 to +1358
Copy link
Member

Choose a reason for hiding this comment

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

Can we just use getOutput here to test both the error message and the (lack of) stdout output, as it's done in other tests?

eslint/tests/bin/eslint.js

Lines 1219 to 1224 in 8662ed1

const outputAssertion = getOutput(child).then(output => {
const expectedSubstring = "Syntax error in selector";
assert.strictEqual(output.stdout, "");
assert.include(output.stderr, expectedSubstring);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did use getOutput first, but the test fails with the error:

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

I think it's because the MCP server process isn't exiting on its own, so getOutput never resolves.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, of course. Then let's go ahead and merge this change. It looks like this resolves situations like https://github.com/eslint/eslint/actions/runs/16801498351/job/47583769079, where the server manages to print its initial debug message to stderr before the process is terminated.

});
});
});
Expand Down
Loading