Skip to content

Commit b0d8d3b

Browse files
简佲(赵智强)claude
andcommitted
fix: 修复 Node.js v23 下 isNewer 测试因布尔值着色而失败
Node.js v23 的 console.log 会对布尔值自动添加 ANSI 颜色码, 导致测试断言比较失败。用 String() 转换后输出以避免着色问题。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ebe3d3a commit b0d8d3b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

test/updater.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ describe('version comparison logic (indirect)', () => {
232232
return execFileSync(process.execPath, ['-e', script], {
233233
encoding: 'utf-8',
234234
timeout: 5000,
235+
env: { ...process.env, NO_COLOR: '1' },
235236
}).trim();
236237
}
237238

@@ -244,32 +245,32 @@ describe('version comparison logic (indirect)', () => {
244245
});
245246

246247
it('isNewer returns true for higher patch', () => {
247-
const out = evalInModule(`console.log(isNewer('1.4.20', '1.4.19'));`);
248+
const out = evalInModule(`console.log(String(isNewer('1.4.20', '1.4.19')));`);
248249
assert.equal(out, 'true');
249250
});
250251

251252
it('isNewer returns false for same version', () => {
252-
const out = evalInModule(`console.log(isNewer('1.4.19', '1.4.19'));`);
253+
const out = evalInModule(`console.log(String(isNewer('1.4.19', '1.4.19')));`);
253254
assert.equal(out, 'false');
254255
});
255256

256257
it('isNewer returns false for older version', () => {
257-
const out = evalInModule(`console.log(isNewer('1.4.18', '1.4.19'));`);
258+
const out = evalInModule(`console.log(String(isNewer('1.4.18', '1.4.19')));`);
258259
assert.equal(out, 'false');
259260
});
260261

261262
it('isNewer handles major version bump', () => {
262-
const out = evalInModule(`console.log(isNewer('2.0.0', '1.9.99'));`);
263+
const out = evalInModule(`console.log(String(isNewer('2.0.0', '1.9.99')));`);
263264
assert.equal(out, 'true');
264265
});
265266

266267
it('isNewer handles minor version bump', () => {
267-
const out = evalInModule(`console.log(isNewer('1.5.0', '1.4.99'));`);
268+
const out = evalInModule(`console.log(String(isNewer('1.5.0', '1.4.99')));`);
268269
assert.equal(out, 'true');
269270
});
270271

271272
it('isNewer: lower major is not newer', () => {
272-
const out = evalInModule(`console.log(isNewer('0.9.99', '1.0.0'));`);
273+
const out = evalInModule(`console.log(String(isNewer('0.9.99', '1.0.0')));`);
273274
assert.equal(out, 'false');
274275
});
275276
});

0 commit comments

Comments
 (0)