Skip to content

Commit

Permalink
test: reduce delays to speed up tests (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt authored May 14, 2024
1 parent c36ce82 commit dde82e2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/__test__/spoof.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
Expand All @@ -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"]')
})
})
Expand Down

0 comments on commit dde82e2

Please sign in to comment.