-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support spawnOpts for geckodriver child process (#552)
* feat: support spawnOpts for geckodriver child process * add documentation on new spawnOpts parameter * correctly reflect spawnOptions argument * update readme docs with correct spawnOpts type
- Loading branch information
1 parent
2b429a4
commit 3edaf8e
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
import cp from 'node:child_process' | ||
import { vi, test, expect } from 'vitest' | ||
import { type GeckodriverParameters, start } from '../src/index.ts' | ||
|
||
test('start', async () => { | ||
vi.mock('../src/install.js', () => { | ||
return { | ||
download: vi.fn().mockResolvedValue('foo') | ||
} | ||
}) | ||
|
||
vi.mock('../src/utils.js', async (original) => { | ||
const actual: any = await original() | ||
return { | ||
hasAccess: vi.fn().mockResolvedValue(true), | ||
parseParams: actual.parseParams | ||
} | ||
}) | ||
|
||
vi.mock('node:child_process', () => ({ | ||
default: { | ||
spawn: vi.fn(), | ||
} | ||
})) | ||
|
||
const args: GeckodriverParameters = { | ||
spawnOpts: { | ||
env: { | ||
MOZ_HEADLESS_WIDTH: '720' | ||
} | ||
} | ||
} | ||
|
||
await start(args) | ||
expect(cp.spawn).toHaveBeenCalledWith('foo', ['--host=0.0.0.0', '--websocket-port=0'], { | ||
env: { | ||
MOZ_HEADLESS_WIDTH: '720' | ||
} | ||
}) | ||
}) |