Skip to content

Commit

Permalink
Merge branch 'master' into style/style-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt committed May 14, 2024
2 parents ff72f70 + dde82e2 commit a9c94a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "lib/spoof.d.ts",
"scripts": {
"prepare": "husky && yarn lint && yarn build",
"build": "tsc",
"build": "tsc -p tsconfig.build.json",
"lint": "yarn ts-standard --fix",
"test": "jest"
},
Expand Down
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
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"exclude": ["node_modules", "**/__test__/**/*"]
}

0 comments on commit a9c94a5

Please sign in to comment.