-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathversion.test.ts
More file actions
38 lines (32 loc) · 1.14 KB
/
version.test.ts
File metadata and controls
38 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {describe, it, afterEach} from 'node:test';
import assert from 'node:assert';
import sinon from 'sinon';
describe('version check', () => {
afterEach(() => {
sinon.restore();
});
it('should exit if node version is not supported', async (t) => {
const processExit = sinon.stub(process, 'exit');
const consoleError = sinon.stub(console, 'error');
await t.test('v21.0.0', async () => {
Object.defineProperty(process, 'version', {
value: 'v21.0.0',
writable: true,
configurable: true,
});
// We need to dynamically import the index with a random query string
// to bypass the module cache and re-evaluate the version check.
await import(`../src/index.js?r=${Math.random()}`);
assert.strictEqual(processExit.callCount, 1);
assert.strictEqual(processExit.getCall(0).args[0], 1);
assert.deepStrictEqual(consoleError.getCall(0).args, [
'ERROR: `chrome-devtools-mcp` does not support Node v21.0.0. Please upgrade to Node 20.19.0 LTS or a newer LTS.',
]);
});
});
});