silverwolf-x/project / test /e2e /app-dir /actions-streaming /actions-streaming.test.ts
silverwolf-x's picture
download
raw
1.27 kB
import { nextTestSetup } from 'e2e-utils'
import { retry, waitFor } from 'next-test-utils'
describe('actions-streaming', () => {
const { next } = nextTestSetup({
files: __dirname,
})
describe('actions returning a ReadableStream', () => {
it('should properly stream the response without buffering', async () => {
const browser = await next.browser('/readable-stream')
await browser.elementById('stream-button').click()
expect(await browser.elementById('stream-button').text()).toBe(
'Streaming...'
)
// If we're streaming properly, we should see the first chunks arrive
// quickly.
expect(await browser.elementByCss('h3').text()).toMatch(
/Received \d+ chunks/
)
expect(await browser.elementById('chunks').text()).toInclude(
'Lorem ipsum dolor sit'
)
// Finally, wait for the response to finish streaming.
await waitFor(5000)
await retry(
async () => {
expect(await browser.elementByCss('h3').text()).toBe(
'Received 50 chunks'
)
expect(await browser.elementById('stream-button').text()).toBe(
'Start Stream'
)
},
10000,
1000
)
})
})
})

Xet Storage Details

Size:
1.27 kB
·
Xet hash:
d7d61ad7531a12567ad1c92191f17c8ce59289874b024486d15bafc9b48268b0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.