mardi 14 janvier 2020

How to mock koa context in a function that returns a function with context parameter

I have a file, myFunction.ts that defines and exports one function:

export function MyFunction() {
    return async (ctx: Koa.Context) => {
        //some work happens in here
    };
}

This function gets called in a Koa middleware file and inherits the ctx from previous middleware. How does one create a mock ctx to test MyFunction() in this case?

Aucun commentaire:

Enregistrer un commentaire