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