Skip to content

Commit a6f4ab9

Browse files
authored
chore(travis): fix puppeteer and coverage issues (#5)
1 parent c6373c6 commit a6f4ab9

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const domLibraryAsString = readFileSync(
99
'utf8',
1010
).replace(/process.env/g, '{}')
1111

12+
/* istanbul ignore next */
1213
function mapArgument(argument: any, index: number): any {
1314
return index === 0 && typeof argument === 'object' && argument.regex
1415
? new RegExp(argument.regex)

test/__snapshots__/extend.test.ts.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
exports[`lib/extend.ts should handle the LabelText methods 1`] = `"<input id=\\"label-text-input\\" type=\\"text\\">"`;
44
55
exports[`lib/extend.ts should handle the get* method failures 1`] = `
6-
[Error: Evaluation failed: Error: Unable to find an element with the title: missing.
6+
"Evaluation failed: Error: Unable to find an element with the title: missing.
77
88
<div
9-
[33mid[39m=[32m"scoped"[39m
9+
[33mid[39m=[32m\\"scoped\\"[39m
1010
>
1111

1212

@@ -16,11 +16,11 @@ exports[`lib/extend.ts should handle the get* method failures 1`] = `
1616

1717

1818
</div>
19-
at getElementError (<anonymous>:2626:11)
20-
at getAllByTitle (<anonymous>:2827:12)
21-
at firstResultOrNull (<anonymous>:2638:31)
22-
at Object.getByTitle (<anonymous>:2837:29)
23-
at evaluateInPage (<anonymous>:3048:41)]
19+
at getElementError <stack>:X:X)
20+
at getAllByTitle <stack>:X:X)
21+
at firstResultOrNull <stack>:X:X)
22+
at Object.getByTitle <stack>:X:X)
23+
at evaluateInPage <stack>:X:X)"
2424
`;
2525
2626
exports[`lib/extend.ts should handle the get* methods 1`] = `"<input type=\\"text\\" data-testid=\\"testid-text-input\\">"`;

test/extend.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('lib/extend.ts', () => {
88
let document: puppeteer.ElementHandle
99

1010
it('should launch puppeteer', async () => {
11-
browser = await puppeteer.launch()
11+
browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']})
1212
page = await browser.newPage()
1313
await page.goto(`file://${path.join(__dirname, 'fixtures/page.html')}`)
1414
})
@@ -21,17 +21,20 @@ describe('lib/extend.ts', () => {
2121
it('should handle the query* methods', async () => {
2222
const element = await document.queryByText('Hello h1')
2323
expect(element).toBeTruthy()
24+
/* istanbul ignore next */
2425
expect(await page.evaluate(el => el.textContent, element)).toEqual('Hello h1')
2526
})
2627

2728
it('should handle regex matching', async () => {
2829
const element = await document.queryByText(/Hello/)
2930
expect(element).toBeTruthy()
31+
/* istanbul ignore next */
3032
expect(await page.evaluate(el => el.textContent, element)).toEqual('Hello h1')
3133
})
3234

3335
it('should handle the get* methods', async () => {
3436
const element = await document.getByTestId('testid-text-input')
37+
/* istanbul ignore next */
3538
expect(await page.evaluate(el => el.outerHTML, element)).toMatchSnapshot()
3639
})
3740

@@ -43,12 +46,14 @@ describe('lib/extend.ts', () => {
4346
await scope.getByTitle('missing')
4447
fail()
4548
} catch (err) {
46-
expect(err).toMatchSnapshot()
49+
err.message = err.message.replace(/\(.*?:\d+:\d+/g, '<stack>:X:X')
50+
expect(err.message).toMatchSnapshot()
4751
}
4852
})
4953

5054
it('should handle the LabelText methods', async () => {
5155
const element = await document.getByLabelText('Label A')
56+
/* istanbul ignore next */
5257
expect(await page.evaluate(el => el.outerHTML, element)).toMatchSnapshot()
5358
})
5459

@@ -68,6 +73,7 @@ describe('lib/extend.ts', () => {
6873
it('should scope results to element', async () => {
6974
const scope = await document.$('#scoped')
7075
const element = await scope.queryByText(/Hello/)
76+
/* istanbul ignore next */
7177
expect(await page.evaluate(el => el.textContent, element)).toEqual('Hello h3')
7278
})
7379

test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('lib/index.ts', () => {
77
let page: puppeteer.Page
88

99
it('should launch puppeteer', async () => {
10-
browser = await puppeteer.launch()
10+
browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']})
1111
page = await browser.newPage()
1212
await page.goto(`file://${path.join(__dirname, 'fixtures/page.html')}`)
1313
})

0 commit comments

Comments
 (0)