Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 095e358

Browse files
authored
Fix selectors registration (#105)
* Fix selectors registration
1 parent 2af022f commit 095e358

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('getPlaywrightInstance', () => {
229229

230230
jest.doMock('playwright', () => ({
231231
firefox: 'firefox',
232-
selectors: { register },
232+
selectors: { _engines: new Map(), register },
233233
}))
234234

235235
const selectors = [{ name: 'test', script: 'test' }]

src/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ export const getPlaywrightInstance = async (
8989
const playwright = require('playwright')
9090
if (selectors) {
9191
await Promise.all(
92-
selectors.map(({ name, script }) =>
93-
playwright.selectors.register(name, script),
94-
),
92+
selectors.map(({ name, script }) => {
93+
if (!playwright.selectors._engines.get(name)) {
94+
return playwright.selectors.register(name, script)
95+
}
96+
}),
9597
)
9698
}
9799
return playwright[browserType]

0 commit comments

Comments
 (0)