Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit c29612e

Browse files
jrolfsdependabot-preview[bot]dependabot[bot]
authored
🚚 Move tests back / ⬆️ Upgrade @hover/javascript (#88)
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 7c16edb commit c29612e

File tree

11 files changed

+1745
-1290
lines changed

11 files changed

+1745
-1290
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
coverage/
3+
dist/
4+
extend.js
5+
extend.d.ts

.eslintrc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const { overrides, ...config } = require('@hover/javascript/eslint')
1+
const {overrides, ...config} = require('@hover/javascript/eslint')
22

33
module.exports = {
44
...config,
55
ignorePatterns: ['dom-testing-library.js', 'rollup.input.js'],
66
parserOptions: {
7-
project: ['tsconfig.json', 'tsconfig.eslint.json'],
7+
tsconfigRootDir: __dirname,
8+
project: ['tsconfig.eslint.json', 'tsconfig.json'],
89
},
910
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"wait-for-expect": "^3.0.2"
4949
},
5050
"devDependencies": {
51-
"@hover/javascript": "^4.4.0",
51+
"@hover/javascript": "^4.17.0",
5252
"@rollup/plugin-commonjs": "^15.0.0",
5353
"@rollup/plugin-node-resolve": "^8.0.0",
5454
"@rollup/plugin-replace": "^2.3.1",

lib/__tests__/extend.ts renamed to test/extend.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ describe('lib/extend.ts', () => {
66
let page: playwright.Page
77
let document: playwright.ElementHandle
88

9-
it('should require without error', async () => {
10-
await import('../extend')
11-
})
9+
beforeAll(async () => {
10+
await import('../lib/extend')
1211

13-
it('should launch playwright', async () => {
1412
browser = await playwright.chromium.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']})
1513
page = await browser.newPage()
14+
1615
await page.goto(`file://${path.join(__dirname, 'fixtures/page.html')}`)
16+
17+
document = await page.getDocument()
1718
})
1819

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

@@ -57,6 +57,7 @@ describe('lib/extend.ts', () => {
5757
fail() // eslint-disable-line jest/no-jasmine-globals
5858
} catch (err) {
5959
err.message = err.message.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
60+
// eslint-disable-next-line jest/no-try-expect
6061
expect(err.message).toMatchSnapshot()
6162
}
6263
})
File renamed without changes.
File renamed without changes.

lib/__tests__/index.ts renamed to test/index.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as path from 'path'
22
import * as playwright from 'playwright'
3-
import {getDocument, queries, getQueriesForElement, waitFor, configure} from '..'
3+
import {getDocument, queries, getQueriesForElement, waitFor, configure} from '../lib'
44

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

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

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

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

6969
afterEach(() => {
7070
configure({testIdAttribute: 'data-testid'}) // cleanup

tsconfig.eslint.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
"compilerOptions": {
44
"allowJs": true
55
},
6-
"include": ["lib/**/__tests__/**/*", "**/*.config.js"],
7-
"exclude": []
6+
"include": ["test", "**/*.config.js"]
87
}

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
"strictNullChecks": true,
1717
"preserveWatchOutput": true
1818
},
19-
"include": ["lib"],
20-
"exclude": ["**/__tests__/**/*"]
19+
"include": ["lib"]
2120
}

0 commit comments

Comments
 (0)