-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add driver.close assertions (#479)
* test: add driver.close assertions * test: play nice with the rest of tests
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict' | ||
|
||
const { createBrowser } = require('@browserless/test/util') | ||
const psList = require('ps-list') | ||
const isCI = require('is-ci') | ||
const test = require('ava') | ||
|
||
const getChromiumPs = async () => { | ||
const ps = await psList() | ||
return ps.filter(ps => ps.name.includes('Chromium')) | ||
} | ||
|
||
;(isCI ? test.skip : test.serial)('.close() will kill process and subprocess', async t => { | ||
const initialPs = await getChromiumPs() | ||
|
||
const browserlessFactory = createBrowser() | ||
t.teardown(() => browserlessFactory.close()) | ||
|
||
t.is((await getChromiumPs()).length, 1) | ||
t.is((await getChromiumPs())[0].pid, (await browserlessFactory.browser()).process().pid) | ||
|
||
const browserless = await browserlessFactory.createContext() | ||
t.is((await getChromiumPs()).length, 3) | ||
|
||
await browserless.destroyContext() | ||
t.is((await getChromiumPs()).length, 3) | ||
|
||
await browserlessFactory.close() | ||
t.is((await getChromiumPs()).length, initialPs) | ||
}) | ||
|
||
;(isCI ? test.skip : test.serial)('.close() is idempotency', async t => { | ||
const initialPs = await getChromiumPs() | ||
|
||
const browserlessFactory = createBrowser() | ||
t.is((await getChromiumPs()).length, 1) | ||
|
||
await browserlessFactory.close() | ||
t.is((await getChromiumPs()).length, initialPs) | ||
|
||
await browserlessFactory.close() | ||
t.is((await getChromiumPs()).length, initialPs) | ||
}) |