Closed yoodu closed 3 years ago
函数定义如下,单元测试执行结果为:{"message":"test"} ,而通过线上调用正常。
@Func('account.test') async test() { const { pName, mail } = this.ctx.query console.log('test', pName) //结果为test undefined return { message: 'test', pName, mail, } }
index.text.ts 如下
import { invoke } from '@midwayjs/serverless-invoke' import { HTTPTrigger } from '@midwayjs/serverless-fc-trigger' describe('/test/index.test.ts', () => { it('test', async () => { const result = await invoke({ functionName: 'test', data: [ new HTTPTrigger({ path: '/account/test', method: 'GET', query: { pName: 'aaa', mail: 'f@s.com' }, }), ], }) assert.equal(result.vcode.length, 6) })
@yoodu 参考 https://github.com/midwayjs/cli/blob/master/packages/faas-cli-plugin-invoke/test/http.test.ts
还是一样不行
我们单测是过的,没问题的,贴下你的仓库?
函数定义如下,单元测试执行结果为:{"message":"test"} ,而通过线上调用正常。
index.text.ts 如下