From 7a353a3c8c3030fbbdcf5a92e26d222314ef9307 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:00:02 -0400 Subject: [PATCH] test: fix desktopCapturer restore-token specs on main (#55118) The restore-token specs added in #54550 were written against a base that predated #54439, which dropped chai/chai-as-promised/dirty-chai in favour of vitest's own matchers and added the no-chai-assertions lint rule. On main, `.to.be.eventually.rejectedWith()` and `.to.be.empty()` throw at runtime and every chai chain trips lint. Switch them to vitest matchers. Claude-Session: https://claude.ai/code/session_012AdLYu5PBMGgRbsE7frDma Co-authored-by: Claude --- spec/api-desktop-capturer.spec.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/spec/api-desktop-capturer.spec.ts b/spec/api-desktop-capturer.spec.ts index b1a56e6a11..4065aea3da 100644 --- a/spec/api-desktop-capturer.spec.ts +++ b/spec/api-desktop-capturer.spec.ts @@ -29,12 +29,12 @@ describe('desktopCapturer', { tags: ['serial'] }, () => { it('throws an error for an unknown persistMode', async () => { const promise = desktopCapturer.getSources({ types: getSourceTypes(), persistMode: 'forever' as any }); - await expect(promise).to.be.eventually.rejectedWith(Error, 'Invalid options'); + await expect(promise).rejects.toThrow('Invalid options'); }); it('throws an error for a non-string restoreToken', async () => { const promise = desktopCapturer.getSources({ types: getSourceTypes(), restoreToken: 42 as any }); - await expect(promise).to.be.eventually.rejectedWith(Error, 'Invalid options'); + await expect(promise).rejects.toThrow('Invalid options'); }); it('accepts persistMode and restoreToken and returns a restoreToken for each source', async () => { @@ -44,21 +44,22 @@ describe('desktopCapturer', { tags: ['serial'] }, () => { persistMode: 'transient', restoreToken: '' }); - expect(sources).to.be.an('array').that.is.not.empty(); + expect(sources).toBeInstanceOf(Array); + expect(sources).not.toHaveLength(0); for (const source of sources) { - expect(source.restoreToken).to.be.a('string'); - if (!isWayland) expect(source.restoreToken).to.be.empty(); + expect(source.restoreToken).toBeTypeOf('string'); + if (!isWayland) expect(source.restoreToken).toBe(''); } }); it('throws when restoreToken is passed without persistMode', async () => { const promise = desktopCapturer.getSources({ types: getSourceTypes(), restoreToken: 'token' }); - await expect(promise).to.be.eventually.rejectedWith(Error, 'Invalid options'); + await expect(promise).rejects.toThrow('Invalid options'); }); it('getRestoreToken returns an empty string for a source that has no token', () => { - expect(desktopCapturer.getRestoreToken('window:0:0')).to.equal(''); - expect(desktopCapturer.getRestoreToken('not-a-source-id')).to.equal(''); + expect(desktopCapturer.getRestoreToken('window:0:0')).toBe(''); + expect(desktopCapturer.getRestoreToken('not-a-source-id')).toBe(''); }); it('getRestoreToken returns the restoreToken of a returned source', async () => { @@ -66,9 +67,10 @@ describe('desktopCapturer', { tags: ['serial'] }, () => { types: getSourceTypes(), thumbnailSize: { width: 0, height: 0 } }); - expect(sources).to.be.an('array').that.is.not.empty(); + expect(sources).toBeInstanceOf(Array); + expect(sources).not.toHaveLength(0); for (const source of sources) { - expect(desktopCapturer.getRestoreToken(source.id)).to.equal(source.restoreToken); + expect(desktopCapturer.getRestoreToken(source.id)).toBe(source.restoreToken); } });