mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
/**
|
|
* Confirm basic behaviors of puppeteer assertions
|
|
*/
|
|
|
|
import { testURL } from '../testURL'
|
|
import { expectToFind, expectToNotFind, expectToReject } from '../utils'
|
|
|
|
describe(`in random page`, () => {
|
|
beforeAll(() => page.goto(testURL`https://google.com`))
|
|
|
|
it('wait for hidden non-exist element should resolve null', async () => {
|
|
expect(
|
|
await page.waitForSelector('.non-exist-element', { hidden: true, timeout: 1000 }),
|
|
).toBeNull()
|
|
})
|
|
|
|
it('wait for exist element', async () => {
|
|
expectToFind('*')
|
|
})
|
|
|
|
it('wait for exist element', async () => {
|
|
expectToNotFind('.non-exist-element')
|
|
})
|
|
|
|
it('wait for non-exist element reject should throw', async () => {
|
|
await expectToReject(page.waitForSelector('.non-exist-element', { timeout: 1000 }))
|
|
})
|
|
|
|
// Cases below are expected to fail to show how async test works
|
|
|
|
// // This is expected to fail!
|
|
// it('wait for non-exist element reject should not throw', async () => {
|
|
// await expect(
|
|
// page.waitForSelector('.non-exist-element', { timeout: 1000 }),
|
|
// ).rejects.not.toThrow()
|
|
// })
|
|
|
|
// // This is expected to fail!
|
|
// it('wait for non-exist element should resolve throw', async () => {
|
|
// await expect(page.waitForSelector('.non-exist-element', { timeout: 1000 })).resolves.toThrow()
|
|
// })
|
|
|
|
// // This is expected to fail!
|
|
// it('wait for non-exist element should resolve not throw', async () => {
|
|
// await expect(
|
|
// page.waitForSelector('.non-exist-element', { timeout: 1000 }),
|
|
// ).resolves.not.toThrow()
|
|
// })
|
|
})
|