Documents / @faasjs/test / FuncWarper
Class: FuncWarper
Test Wrapper for a func
import { FuncWarper } from '@faasjs/test'
import Func from '../demo.func.ts'
const func = new FuncWarper(Func)
expect(await func.handler()).toEqual('Hello, world')
Indexable
[key
: string
]: any
Constructors
new FuncWarper()
new FuncWarper(
initBy
):FuncWarper
Parameters
initBy
Returns
Methods
handler()
handler<
TResult
>(event
,context
):Promise
<TResult
>
Type Parameters
• TResult = any
Parameters
event
any
= ...
context
any
= ...
Returns
Promise
<TResult
>
JSONhandler()
JSONhandler<
TData
>(body
?,options
?):Promise
<{body
:any
;cookie
:Record
<string
,any
>;data
:TData
;error
: {message
:string
; };headers
: {};session
:Record
<string
,any
>;statusCode
:number
; }>
Type Parameters
• TData = any
Parameters
body?
options?
cookie
{}
headers
{}
session
{}
Returns
Promise
<{ body
: any
; cookie
: Record
<string
, any
>; data
: TData
; error
: { message
: string
; }; headers
: {}; session
: Record
<string
, any
>; statusCode
: number
; }>
mount()
mount(
handler
?):Promise
<void
>
Parameters
handler?
(func
) => void
| Promise
<void
>
Returns
Promise
<void
>
Properties
config
readonly
config:Config
file
readonly
file:string
func
readonly
func:Func
logger
readonly
logger:Logger
plugins
readonly
plugins:Plugin
[]
staging
readonly
staging:string