mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-28 16:42:04 +00:00
test: properly close page
in e2e tests
This commit is contained in:
parent
4782e3c90a
commit
1700aa131a
@ -130,7 +130,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.navigate('/scroll-to-top/scroll-to-top-true')
|
||||
const pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBe(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/scroll-to-top with scrollToTop set to false', async () => {
|
||||
@ -139,7 +139,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.navigate('/scroll-to-top/scroll-to-top-false')
|
||||
const pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBeGreaterThan(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/scroll-to-top in the same page', async () => {
|
||||
@ -148,7 +148,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.navigate('/scroll-to-top?test=1')
|
||||
const pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBeGreaterThan(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/scroll-to-top in the same page with watchQuery: true', async () => {
|
||||
@ -160,7 +160,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.go(-1)
|
||||
pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBeGreaterThan(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/scroll-to-top in the same page with watchQuery array', async () => {
|
||||
@ -178,7 +178,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.go(-1)
|
||||
pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBeGreaterThan(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/scroll-to-top in the same page with watchQuery function', async () => {
|
||||
@ -196,7 +196,7 @@ describe('basic browser', () => {
|
||||
await page.nuxt.go(-1)
|
||||
pageYOffset = await page.evaluate(() => window.pageYOffset)
|
||||
expect(pageYOffset).toBe(0)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/validate should display a 404', async () => {
|
||||
@ -264,7 +264,7 @@ describe('basic browser', () => {
|
||||
await page.waitForFunction(
|
||||
() => window.location.href === 'https://example.com/test/'
|
||||
)
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/redirect-name', async () => {
|
||||
@ -308,6 +308,7 @@ describe('basic browser', () => {
|
||||
|
||||
const p = await page.$text('p')
|
||||
expect(p).toBe('Nuxt')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/refresh-page-data', async () => {
|
||||
@ -317,12 +318,13 @@ describe('basic browser', () => {
|
||||
await page.evaluate($nuxt => $nuxt.refresh(), page.$nuxt)
|
||||
h1 = await page.$text('h1')
|
||||
expect(h1).toContain('Hello from client')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/redirection/no loop', async () => {
|
||||
const page = await browser.page(url('/redirection/no loop'))
|
||||
expect(await page.$text('h1')).toContain('Redirected page')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
@ -332,7 +334,6 @@ describe('basic browser', () => {
|
||||
|
||||
// Stop browser
|
||||
afterAll(async () => {
|
||||
await page.close()
|
||||
await browser.close()
|
||||
})
|
||||
})
|
||||
|
@ -99,6 +99,7 @@ describe('basic browser', () => {
|
||||
])
|
||||
expect(await page.$text('div')).toContain('foo-bar-baz')
|
||||
expect(await page.$text('div')).toContain('fizz-buzz')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /nested', async () => {
|
||||
@ -112,6 +113,7 @@ describe('basic browser', () => {
|
||||
'ie0'
|
||||
])
|
||||
expect(await page.$text('button')).toContain('has fetch')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /nested/child', async () => {
|
||||
@ -127,12 +129,13 @@ describe('basic browser', () => {
|
||||
expect(team.includes('Atinux'))
|
||||
expect(await page.$text('div')).toContain('foo-bar-baz')
|
||||
expect(await page.$text('div')).toContain('fizz-buzz')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-root', async () => {
|
||||
const page = await browser.page(url('/fetch-root'))
|
||||
expect(await page.$text('button')).toContain('has fetch')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-client', async () => {
|
||||
@ -140,13 +143,13 @@ describe('basic browser', () => {
|
||||
expect(await page.$text('p')).toContain('Fetching...')
|
||||
await page.waitForSelector('pre')
|
||||
expect(await page.$text('pre')).toContain('pi0')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-conditional', async () => {
|
||||
const page = await browser.page(url('/fetch-conditional'))
|
||||
expect(await page.$text('pre')).toContain('galvez')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-conditional?fetch_client=true', async () => {
|
||||
@ -154,13 +157,13 @@ describe('basic browser', () => {
|
||||
expect(await page.$text('p')).toContain('Fetching...')
|
||||
await page.waitForSelector('pre')
|
||||
expect(await page.$text('pre')).toContain('pimlie')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-error', async () => {
|
||||
const page = await browser.page(url('/fetch-error'))
|
||||
expect(await page.$text('#error')).toContain('fetch-error')
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('ssr: /fetch-deep', async () => {
|
||||
@ -200,7 +203,7 @@ describe('basic browser', () => {
|
||||
async2: 'data2fetch'
|
||||
})
|
||||
|
||||
page.close()
|
||||
await page.close()
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
@ -210,7 +213,6 @@ describe('basic browser', () => {
|
||||
|
||||
// Stop browser
|
||||
afterAll(async () => {
|
||||
await page.close()
|
||||
await browser.close()
|
||||
})
|
||||
})
|
||||
|
@ -6,7 +6,6 @@ const browser = new Browser()
|
||||
const url = route => 'http://127.0.0.1:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
let page = null
|
||||
|
||||
describe('spa router base browser', () => {
|
||||
beforeAll(async () => {
|
||||
@ -24,7 +23,7 @@ describe('spa router base browser', () => {
|
||||
})
|
||||
|
||||
test('Open /app (router base)', async () => {
|
||||
page = await browser.page(url('/app'))
|
||||
const page = await browser.page(url('/app'))
|
||||
|
||||
expect(await page.evaluate(() => location.href)).toBe(url('/app/'))
|
||||
|
||||
@ -34,28 +33,32 @@ describe('spa router base browser', () => {
|
||||
const headings = document.evaluate("//div[text()='Hello SPA!']", document, null, XPathResult.ANY_TYPE, null)
|
||||
return headings.iterateNext()
|
||||
})).not.toBe(null)
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('Open /app/ (router base with trailing slash)', async () => {
|
||||
page = await browser.page(url('/app/'))
|
||||
const page = await browser.page(url('/app/'))
|
||||
|
||||
expect(await page.evaluate(() => location.href)).toBe(url('/app/'))
|
||||
|
||||
expect(await page.html()).not.toContain('This page could not be found')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('Open /app/mounted', async () => {
|
||||
page = await browser.page(url('/app/mounted'))
|
||||
const page = await browser.page(url('/app/mounted'))
|
||||
|
||||
expect(await page.$text('h1')).toMatch('Test: updated')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
test('/app/unknown', async () => {
|
||||
page = await browser.page(url('/app/unknown'))
|
||||
const page = await browser.page(url('/app/unknown'))
|
||||
|
||||
expect(await page.evaluate(() => location.href)).toBe(url('/app/unknown'))
|
||||
|
||||
expect(await page.html()).toContain('This page could not be found')
|
||||
await page.close()
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
@ -65,7 +68,6 @@ describe('spa router base browser', () => {
|
||||
|
||||
// Stop browser
|
||||
afterAll(async () => {
|
||||
await page.close()
|
||||
await browser.close()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user