Skip to content

Commit

Permalink
fix(dependencies): Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsonchuong committed Aug 8, 2021
1 parent aa80b07 commit 5caab1f
Show file tree
Hide file tree
Showing 21 changed files with 702 additions and 1,570 deletions.
2 changes: 1 addition & 1 deletion actions/click-element/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('clicking an element', async (t) => {
<meta charset="utf-8">
<span id="statusText"></span>
<button onClick="statusText.textContent = 'Clicked'">Click Here</button>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand Down
4 changes: 2 additions & 2 deletions actions/close-browser/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava'
import {
findProcess,
waitForProcess,
withChromePath
withChromePath,
} from '../../test/helpers/index.js'
import {openBrowser, closeBrowser} from '../../index.js'

Expand All @@ -11,7 +11,7 @@ withChromePath(test)
test('closing a browser', async (t) => {
const browser = await openBrowser(global.chromePath)
const {
puppeteer: {browser: puppeteerBrowser}
puppeteer: {browser: puppeteerBrowser},
} = browser

t.truthy(await waitForProcess(puppeteerBrowser.process()))
Expand Down
4 changes: 2 additions & 2 deletions actions/close-tab/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava'
import {
withChromePerTest,
withDirectory,
writeFile
writeFile,
} from '../../test/helpers/index.js'
import {openTab, closeTab} from '../../index.js'

Expand All @@ -18,7 +18,7 @@ test('closing tabs', async (t) => {
`
<!doctype html>
<meta charset="utf-8">
`
`,
)

const tab1 = await openTab(browser, `file://${filePath}`)
Expand Down
8 changes: 4 additions & 4 deletions actions/eval-in-tab/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('executing code within the browser', async (t) => {
<!doctype html>
<meta charset="utf-8">
<div id="root">Hello World!</div>
`
`,
)
const tab = await openTab(browser, `file://${filePath}`)

Expand All @@ -26,7 +26,7 @@ test('executing code within the browser', async (t) => {
`
const [selector] = arguments
return document.querySelector(selector).textContent
`
`,
)
t.is(text, 'Hello World!')
})
Expand All @@ -42,11 +42,11 @@ test('propagating error messages', async (t) => {
<!doctype html>
<meta charset="utf-8">
<div id="root">Hello World!</div>
`
`,
)
const tab = await openTab(browser, `file://${filePath}`)

await t.throwsAsync(evalInTab(tab, [], 'throw new Error("Error Message")'), {
message: /Error: Error Message/
message: /Error: Error Message/,
})
})
2 changes: 1 addition & 1 deletion actions/fill-in-element/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default async function ({puppeteer: {frame, elementHandle}}, text) {
const [element] = arguments
element.blur()
`),
elementHandle
elementHandle,
)
}
6 changes: 3 additions & 3 deletions actions/fill-in-element/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('filling in an element', async (t) => {
<meta charset="utf-8">
<span id="statusText"></span>
<input onChange="statusText.textContent = this.value">
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -38,7 +38,7 @@ test('filling in an element in an iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<iframe src="frame.html"></iframe>
`
`,
)

await writeFile(
Expand All @@ -49,7 +49,7 @@ test('filling in an element in an iframe', async (t) => {
<meta charset="utf-8">
<span id="statusText"></span>
<input onChange="statusText.textContent = this.value">
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand Down
14 changes: 7 additions & 7 deletions actions/find-element/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default async function (tab, selector, text, {timeout = 5000} = {}) {
const {
puppeteer: {browser, page}
puppeteer: {browser, page},
} = tab

try {
Expand All @@ -17,10 +17,10 @@ export default async function (tab, selector, text, {timeout = 5000} = {}) {
`),
{timeout},
selector,
text
text,
)
: await frame.waitForSelector(selector, {timeout})
])
: await frame.waitForSelector(selector, {timeout}),
]),
)

const metadata = await frame.evaluate(
Expand All @@ -38,18 +38,18 @@ export default async function (tab, selector, text, {timeout = 5000} = {}) {
outerHTML: element.outerHTML
}
`),
elementHandle
elementHandle,
)

return {
...metadata,
puppeteer: {browser, page, frame, elementHandle}
puppeteer: {browser, page, frame, elementHandle},
}
} catch {
throw new Error(
`Could not find element with selector "${selector}"${
text ? ` and text "${text}"` : ''
}`
}`,
)
}
}
32 changes: 16 additions & 16 deletions actions/find-element/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('finding an element', async (t) => {
<!doctype html>
<meta charset="utf-8">
<p>Hello World!</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -40,7 +40,7 @@ test('finding an invisible element', async (t) => {
}
</style>
<p>Hello World!</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -59,7 +59,7 @@ test('finding an element in an iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<iframe src="frame.html"></iframe>
`
`,
)

await writeFile(
Expand All @@ -69,7 +69,7 @@ test('finding an element in an iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<p>Hello World!</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -88,7 +88,7 @@ test('finding an element in a nested iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<iframe src="frame1.html"></iframe>
`
`,
)

await writeFile(
Expand All @@ -98,7 +98,7 @@ test('finding an element in a nested iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<iframe src="frame2.html"></iframe>
`
`,
)

await writeFile(
Expand All @@ -108,7 +108,7 @@ test('finding an element in a nested iframe', async (t) => {
<!doctype html>
<meta charset="utf-8">
<p>Hello World!</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -126,12 +126,12 @@ test('failing to find an element', async (t) => {
`
<!doctype html>
<meta charset="utf-8">
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
await t.throwsAsync(findElement(tab, 'p'), {
message: 'Could not find element with selector "p"'
message: 'Could not find element with selector "p"',
})
})

Expand All @@ -147,7 +147,7 @@ test('finding an element containing text', async (t) => {
<meta charset="utf-8">
<p>Hello World!</p>
<p>Other Stuff</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -166,12 +166,12 @@ test('failing to find an element containing text', async (t) => {
<!doctype html>
<meta charset="utf-8">
<p>Hello World!</p>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
await t.throwsAsync(findElement(tab, 'p', 'Other Stuff'), {
message: 'Could not find element with selector "p" and text "Other Stuff"'
message: 'Could not find element with selector "p" and text "Other Stuff"',
})
})

Expand All @@ -190,7 +190,7 @@ test('waiting for an element to appear', async (t) => {
document.body.innerHTML = '<p>Hello World!</p>'
}, 2000)
</script>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand All @@ -213,12 +213,12 @@ test('failing to find an element after 5 seconds', async (t) => {
document.body.innerHTML = '<p>Hello World!</p>'
}, 10000)
</script>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
await t.throwsAsync(findElement(tab, 'p'), {
message: 'Could not find element with selector "p"'
message: 'Could not find element with selector "p"',
})
})

Expand All @@ -237,7 +237,7 @@ test('waiting a custom amount of time for an element to appear', async (t) => {
document.body.innerHTML = '<p>Hello World!</p>'
}, 7000)
</script>
`
`,
)

const tab = await openTab(browser, `file://${htmlPath}`)
Expand Down
8 changes: 4 additions & 4 deletions actions/get-tabs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import test from 'ava'
import {
withDirectory,
writeFile,
withChromePath
withChromePath,
} from '../../test/helpers/index.js'
import {
openBrowser,
closeBrowser,
openTab,
getTabs,
findElement
findElement,
} from '../../index.js'

withChromePath(test)
Expand All @@ -26,7 +26,7 @@ test('listing the currently open tabs', async (t) => {
<!doctype html>
<meta charset="utf-8">
<div>One</div>
`
`,
)

const twoPath = await writeFile(
Expand All @@ -36,7 +36,7 @@ test('listing the currently open tabs', async (t) => {
<!doctype html>
<meta charset="utf-8">
<div>Two</div>
`
`,
)

await openTab(browser, `file://${onePath}`)
Expand Down
2 changes: 1 addition & 1 deletion actions/navigate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default async function ({puppeteer: {page}}, url, options = {}) {
try {
await page.goto(url, {
waitUntil: ['load', 'domcontentloaded', 'networkidle0'],
timeout: options.timeout || 5000
timeout: options.timeout || 5000,
})
} catch (error) {
throw new Error(`Failed to navigate: ${error.message}`)
Expand Down
4 changes: 2 additions & 2 deletions actions/open-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default async function (executablePath, options = {}) {
// environments
'--no-sandbox',
'--disable-setuid-sandbox',
...(options.flags || [])
]
...(options.flags || []),
],
})

// Chrome defaults to opening a single blank tab
Expand Down
10 changes: 5 additions & 5 deletions actions/open-browser/opening-a-browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ withChromePath(test)

test('starting headless by default', async (t) => {
const {
puppeteer: {browser}
puppeteer: {browser},
} = await openBrowser(global.chromePath)
// $FlowFixMe
t.true(browser.process().spawnargs.includes('--headless'))
Expand All @@ -15,15 +15,15 @@ test('starting headless by default', async (t) => {

test('starting with 0 tabs open', async (t) => {
const {
puppeteer: {browser}
puppeteer: {browser},
} = await openBrowser(global.chromePath)
t.deepEqual(await browser.pages(), [])
await browser.close()
})

test('starting Chrome headlessly', async (t) => {
const {
puppeteer: {browser}
puppeteer: {browser},
} = await openBrowser(global.chromePath, {headless: true})
// $FlowFixMe
t.true(browser.process().spawnargs.includes('--headless'))
Expand All @@ -32,7 +32,7 @@ test('starting Chrome headlessly', async (t) => {

test('starting Chrome headfully', async (t) => {
const {
puppeteer: {browser}
puppeteer: {browser},
} = await openBrowser(global.chromePath, {headless: false})
// $FlowFixMe
t.false(browser.process().spawnargs.includes('--headless'))
Expand All @@ -41,7 +41,7 @@ test('starting Chrome headfully', async (t) => {

test('starting Chrome with additional flags', async (t) => {
const {
puppeteer: {browser}
puppeteer: {browser},
} = await openBrowser(global.chromePath, {flags: ['--bwsi']})
// $FlowFixMe
t.true(browser.process().spawnargs.includes('--bwsi'))
Expand Down
Loading

0 comments on commit 5caab1f

Please sign in to comment.