Nihilist Pocket Monsters

    @faasjs/test
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3-beta.4 • Public • Published

    @faasjs/test

    License: MIT NPM Stable Version NPM Beta Version

    FaasJS's testing module.

    Install

    npm install @faasjs/test
    

    Modules

    Classes

    Type Aliases

    Functions

    Type Aliases

    Config

    Ƭ Config: Object

    Index signature

    [key: string]: any

    Type declaration

    Name Type
    plugins? { [key: string]: { [key: string]: any; config?: { [key: string]: any; } ; provider?: string | ProviderConfig ; type: string }; }
    providers? { [key: string]: ProviderConfig; }

    DeployData

    Ƭ DeployData: Object

    Index signature

    [key: string]: any

    Type declaration

    Name Type
    config? Config
    dependencies { [name: string]: string; }
    env? string
    filename string
    logger? Logger
    name? string
    plugins? { [name: string]: { [key: string]: any; config: { [key: string]: any; } ; name?: string ; plugin: Plugin ; provider?: string ; type: string }; }
    root string
    version? string

    ExportedHandler

    Ƭ ExportedHandler<TEvent, TContext, TResult>: (event: TEvent, context?: TContext, callback?: (...args: any) => any) => Promise<TResult>

    Type parameters

    Name Type
    TEvent any
    TContext any
    TResult any

    Type declaration

    ▸ (event, context?, callback?): Promise<TResult>

    Parameters
    Name Type
    event TEvent
    context? TContext
    callback? (...args: any) => any
    Returns

    Promise<TResult>


    FuncConfig

    Ƭ FuncConfig<TEvent, TContext, TResult>: Object

    Type parameters

    Name Type
    TEvent any
    TContext any
    TResult any

    Type declaration

    Name Type
    handler? Handler<TEvent, TContext, TResult>
    plugins? Plugin[]

    Handler

    Ƭ Handler<TEvent, TContext, TResult>: (data: InvokeData<TEvent, TContext>) => Promise<TResult>

    Type parameters

    Name Type
    TEvent any
    TContext any
    TResult any

    Type declaration

    ▸ (data): Promise<TResult>

    Parameters
    Name Type
    data InvokeData<TEvent, TContext>
    Returns

    Promise<TResult>


    InvokeData

    Ƭ InvokeData<TEvent, TContext, TResult>: Object

    Type parameters

    Name Type
    TEvent any
    TContext any
    TResult any

    Index signature

    [key: string]: any

    Type declaration

    Name Type
    callback any
    config Config
    context TContext
    event TEvent
    handler? Handler<TEvent, TContext, TResult>
    logger Logger
    response any

    LifeCycleKey

    Ƭ LifeCycleKey: "onDeploy" | "onMount" | "onInvoke"


    MountData

    Ƭ MountData: Object

    Index signature

    [key: string]: any

    Type declaration

    Name Type
    config Config
    context any
    event any

    Next

    Ƭ Next: () => Promise<void>

    Type declaration

    ▸ (): Promise<void>

    Returns

    Promise<void>


    Plugin

    Ƭ Plugin: Object

    Index signature

    [key: string]: any

    Type declaration

    Name Type
    name string
    onDeploy? (data: DeployData, next: Next) => void | Promise<void>
    onInvoke? (data: InvokeData, next: Next) => void | Promise<void>
    onMount? (data: MountData, next: Next) => void | Promise<void>
    type string

    ProviderConfig

    Ƭ ProviderConfig: Object

    Type declaration

    Name Type
    config { [key: string]: any; }
    type string

    UseifyPlugin

    Ƭ UseifyPlugin: Object

    Type declaration

    Name Type
    mount? (data: { config: Config }) => Promise<void>

    Functions

    test

    test(initBy): FuncWarper

    A simple way to warp a FaasJs function.

    Parameters

    Name Type Description
    initBy string | Func<any, any, any> {string | Func} Full file path or a FaasJs function ts import { test } from '@faasjs/test' text(__dirname + '/../demo.func.ts')) expect(await test.handler()).toEqual('Hello, world')

    Returns

    FuncWarper


    useFunc

    useFunc<TEvent, TContext, TResult>(handler): Func<TEvent, TContext, TResult>

    // pure function
    export default useFunc(() => {
      return () => {
        return 'Hello World'
      }
    })
    
    // with http
    import { useHttp } from '@faasjs/http'
    
    export default useFunc(() => {
      const http = useHttp<{ name: string }>()
    
      return () => {
        return `Hello ${http.params.name}`
      }
    })

    Type parameters

    Name Type
    TEvent any
    TContext any
    TResult any

    Parameters

    Name Type
    handler () => Handler<TEvent, TContext, TResult>

    Returns

    Func<TEvent, TContext, TResult>


    usePlugin

    usePlugin<T>(plugin): T & UseifyPlugin

    Type parameters

    Name Type
    T extends Plugin

    Parameters

    Name Type
    plugin T & UseifyPlugin

    Returns

    T & UseifyPlugin

    Keywords

    none

    Install

    npm i @faasjs/test

    DownloadsWeekly Downloads

    533

    Version

    0.0.3-beta.4

    License

    MIT

    Unpacked Size

    20.7 kB

    Total Files

    7

    Last publish

    Collaborators

    • zfben