Skip to content

chore(deps): update typescript to v3 #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/extend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {getDocument, getQueriesForElement} from '.'
import {ElementHandle} from '../node_modules/@types/puppeteer'

import {getDocument, getQueriesForElement} from '.'
import {IScopedQueryUtils} from './typedefs'

// tslint:disable-next-line
Expand Down
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {readFileSync} from 'fs'
import * as path from 'path'
import {ElementHandle, EvaluateFn, JSHandle, Page} from 'puppeteer'
import waitForExpect from 'wait-for-expect'

import {IQueryUtils, IScopedQueryUtils} from './typedefs'

const domLibraryAsString = readFileSync(
Expand Down Expand Up @@ -32,7 +33,7 @@ type ContextFn = (...args: any[]) => ElementHandle

async function createElementHandleArray(handle: JSHandle): Promise<ElementHandle[]> {
const lengthHandle = await handle.getProperty('length')
const length = await lengthHandle.jsonValue()
const length = await lengthHandle.jsonValue() as number

const elements: ElementHandle[] = []
for (let i = 0; i < length; i++) {
Expand Down
21 changes: 17 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@
"config": {
"tslint": {
"rules": {
"no-unsafe-any": false
"increment-decrement": false,
"no-unsafe-any": false,
"ban-ts-ignore": {
"severity": "warning"
},
"function-constructor": {
"severity": "warning"
},
"strict-comparisons": {
"severity": "warning"
},
"match-default-export-name": {
"severity": "warning"
}
}
},
"exportAliases": {
Expand All @@ -56,9 +69,9 @@
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0",
"typescript": "^2.9.2"
"ts-jest": "^25.2.1",
"tslint": "^6.0.0",
"typescript": "^3.8.3"
},
"peerDependencies": {
"puppeteer": "^1.5.0 || ^2.0.0"
Expand Down
8 changes: 4 additions & 4 deletions test/extend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('lib/extend.ts', () => {
const scope = await document.$('#scoped')

try {
await scope.getByTitle('missing')
await scope!.getByTitle('missing')
fail()
} catch (err) {
err.message = err.message.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
Expand Down Expand Up @@ -82,18 +82,18 @@ describe('lib/extend.ts', () => {

it('should scope results to element', async () => {
const scope = await document.$('#scoped')
const element = await scope.queryByText(/Hello/)
const element = await scope!.queryByText(/Hello/)
/* istanbul ignore next */
expect(await page.evaluate(el => el.textContent, element)).toEqual('Hello h3')
})

it('should get text content', async () => {
const $h3 = await document.$('#scoped h3')
expect(await $h3.getNodeText()).toEqual('Hello h3')
expect(await $h3!.getNodeText()).toEqual('Hello h3')
})

it('should work with destructuring', async () => {
const {queryByText} = (await document.$('#scoped')).getQueriesForElement()
const {queryByText} = (await document.$('#scoped'))!.getQueriesForElement()
expect(await queryByText('Hello h1')).toBeFalsy()
expect(await queryByText('Hello h3')).toBeTruthy()
})
Expand Down
Loading