Skip to content

Commit a827ded

Browse files
committed
fix: failing test for background functions
1 parent 1ea5fb4 commit a827ded

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cypress/e2e/default/api.cy.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ describe('API routes', () => {
88

99
describe('Extended API routes', () => {
1010
it('returns HTTP 202 Accepted for background route', () => {
11-
cy.request('/api/hello-background').then((response) => {
12-
expect(response.status).to.equal(202)
11+
cy.request('POST', 'https://webhook.site/token').then((tokenResponse) => {
12+
const token = tokenResponse.body.uuid
13+
cy.request('POST', `/api/hello-background`, { token }).then((response) => {
14+
expect(response.status).to.equal(202)
15+
16+
cy.wait(100)
17+
18+
cy.request(`https://webhook.site/token/${token}/request/latest`).then(response => {
19+
expect(response.status).to.equal(200)
20+
})
21+
})
1322
})
1423
})
1524
it('correctly returns 404 for scheduled route', () => {

demos/default/pages/api/hello-background.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export default (req, res) => {
1+
export default async (req, res) => {
2+
// await fetch(`https://webhook.site/${req.body.token}`)
3+
24
res.setHeader('Content-Type', 'application/json')
35
res.status(200)
46
res.json({ message: 'hello world :)' })

0 commit comments

Comments
 (0)