From dde82e2f739f08d939d51fe0e8672ccfb1fc273f Mon Sep 17 00:00:00 2001 From: Blake V <87083504+bvandercar-vt@users.noreply.github.com> Date: Mon, 13 May 2024 21:48:39 -0600 Subject: [PATCH] test: reduce delays to speed up tests (#141) --- src/__test__/spoof.spec.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/__test__/spoof.spec.ts b/src/__test__/spoof.spec.ts index 8638810..11b8517 100644 --- a/src/__test__/spoof.spec.ts +++ b/src/__test__/spoof.spec.ts @@ -1,5 +1,5 @@ -import { Page } from 'puppeteer' -import { createCursor, GhostCursor } from '../spoof' +import type { Page } from 'puppeteer' +import { type ClickOptions, createCursor, GhostCursor } from '../spoof' import { join } from 'path' import { promises as fs } from 'fs' import installMouseHelper from '../mouse-helper' @@ -8,6 +8,13 @@ declare const page: Page let cursor: GhostCursor +const cursorDefaultOptions = { + moveDelay: 0, + moveSpeed: 99, + hesitate: 0, + waitForClick: 0 +} as const satisfies ClickOptions + describe('Mouse movements', () => { beforeAll(async () => { await installMouseHelper(page) @@ -17,13 +24,19 @@ describe('Mouse movements', () => { }) }) + beforeEach(() => { + cursor = createCursor(page, undefined, undefined, { + move: cursorDefaultOptions, + click: cursorDefaultOptions, + moveTo: cursorDefaultOptions + }) + }) + it('Should click on the element without throwing an error (CSS selector)', async () => { - cursor = createCursor(page) await cursor.click('#box') }) it('Should click on the element without throwing an error (XPath selector)', async () => { - cursor = createCursor(page) await cursor.click('//*[@id="box"]') }) })