You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consthttp=require('http')constassert=require('assert')constrequest=require('supertest')constKoa=require('koa')constKoaRouter=require('koa-router')constapp=newKoa()constrouter=newKoaRouter()router.prefix('/car/:model')router.param('model',async(model,context,next)=>{assert(model,'Model is not provided')returnawaitnext()})router.use(async(context,next)=>{context.state.reachedThis=truereturnawaitnext()})router.get('/',asynccontext=>{context.body=context.params.model})app.use(router.routes(),router.allowedMethods())request(app.callback()).get('/car/tsx').expect(200).then(()=>console.log('Passed')).catch(console.error)
AssertionError [ERR_ASSERTION]: Model is not provided
at router.param (/home/scrapbook/tutorial/app.js:15:3)
at middleware (/home/scrapbook/tutorial/node_modules/koa-router/lib/layer.js:181:15)
at dispatch (/home/scrapbook/tutorial/node_modules/koa-router/node_modules/koa-compose/index.js:4
4:32)
at next (/home/scrapbook/tutorial/node_modules/koa-router/node_modules/koa-compose/index.js:45:18
)
at /home/scrapbook/tutorial/node_modules/koa-router/lib/router.js:346:16
at dispatch (/home/scrapbook/tutorial/node_modules/koa-router/node_modules/koa-compose/index.js:4
4:32)
at /home/scrapbook/tutorial/node_modules/koa-router/node_modules/koa-compose/index.js:36:12
at dispatch (/home/scrapbook/tutorial/node_modules/koa-router/lib/router.js:351:31)
at dispatch (/home/scrapbook/tutorial/node_modules/koa-compose/index.js:42:32)
at /home/scrapbook/tutorial/node_modules/koa-compose/index.js:34:12
Error: expected 200 "OK", got 500 "Internal Server Error"
at Test._assertStatus (/home/scrapbook/tutorial/node_modules/supertest/lib/test.js:268:12)
at Test._assertFunction (/home/scrapbook/tutorial/node_modules/supertest/lib/test.js:283:11)
at Test.assert (/home/scrapbook/tutorial/node_modules/supertest/lib/test.js:173:18)
at Server.localAssert (/home/scrapbook/tutorial/node_modules/supertest/lib/test.js:131:12)
at Object.onceWrapper (events.js:273:13)
at Server.emit (events.js:182:13)
at emitCloseNT (net.js:1668:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: