Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
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
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
coverage/
dist/
extend.js
extend.d.ts
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { overrides, ...config } = require('@hover/javascript/eslint')
const {overrides, ...config} = require('@hover/javascript/eslint')

module.exports = {
...config,
ignorePatterns: ['dom-testing-library.js', 'rollup.input.js'],
parserOptions: {
project: ['tsconfig.json', 'tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
project: ['tsconfig.eslint.json', 'tsconfig.json'],
},
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"wait-for-expect": "^3.0.2"
},
"devDependencies": {
"@hover/javascript": "^4.4.0",
"@hover/javascript": "^4.17.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.3.1",
Expand Down
11 changes: 6 additions & 5 deletions lib/__tests__/extend.ts → test/extend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ describe('lib/extend.ts', () => {
let page: playwright.Page
let document: playwright.ElementHandle

it('should require without error', async () => {
await import('../extend')
})
beforeAll(async () => {
await import('../lib/extend')

it('should launch playwright', async () => {
browser = await playwright.chromium.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']})
page = await browser.newPage()

await page.goto(`file://${path.join(__dirname, 'fixtures/page.html')}`)

document = await page.getDocument()
})

it('should extend playwright ElementHandle', async () => {
document = await page.getDocument()
expect(typeof document.queryAllByAltText).toBe('function')
})

Expand Down Expand Up @@ -57,6 +57,7 @@ describe('lib/extend.ts', () => {
fail() // eslint-disable-line jest/no-jasmine-globals
} catch (err) {
err.message = err.message.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
// eslint-disable-next-line jest/no-try-expect
expect(err.message).toMatchSnapshot()
}
})
Expand Down
22 changes: 11 additions & 11 deletions lib/__tests__/index.ts → test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as path from 'path'
import * as playwright from 'playwright'
import {getDocument, queries, getQueriesForElement, waitFor, configure} from '..'
import {getDocument, queries, getQueriesForElement, waitFor, configure} from '../lib'

describe('lib/index.ts', () => {
let browser: playwright.Browser
let page: playwright.Page

it('should launch playwright', async () => {
beforeAll(async () => {
browser = await playwright.chromium.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']})
page = await browser.newPage()
await page.goto(`file://${path.join(__dirname, 'fixtures/page.html')}`)
Expand Down Expand Up @@ -55,16 +55,16 @@ describe('lib/index.ts', () => {
expect(await queries.getNodeText(element)).toEqual('Hello h1')
})

it('should load the defered page', async () => {
await page.goto(`file://${path.join(__dirname, 'fixtures/late-page.html')}`)
})
describe('loading the deferred page', () => {
beforeEach(async () => page.goto(`file://${path.join(__dirname, 'fixtures/late-page.html')}`))

it('should use `wait` properly', async () => {
const {getByText} = getQueriesForElement(await getDocument(page))
// eslint-disable-next-line @typescript-eslint/no-misused-promises
await waitFor(() => getByText('Loaded!'), {timeout: 7000})
expect(await getByText('Loaded!')).toBeTruthy()
}, 9000)
it('should use `wait` properly', async () => {
const {getByText} = getQueriesForElement(await getDocument(page))
// eslint-disable-next-line @typescript-eslint/no-misused-promises
await waitFor(() => getByText('Loaded!'), {timeout: 7000})
expect(await getByText('Loaded!')).toBeTruthy()
}, 9000)
})

afterEach(() => {
configure({testIdAttribute: 'data-testid'}) // cleanup
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"compilerOptions": {
"allowJs": true
},
"include": ["lib/**/__tests__/**/*", "**/*.config.js"],
"exclude": []
"include": ["test", "**/*.config.js"]
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"strictNullChecks": true,
"preserveWatchOutput": true
},
"include": ["lib"],
"exclude": ["**/__tests__/**/*"]
"include": ["lib"]
}
Loading