testdouble.js icon indicating copy to clipboard operation
testdouble.js copied to clipboard

Add td.asyncFunc

Open searls opened this issue 7 years ago • 2 comments

There has been some intermittent discussion of how we can make the tdjs API feel terser for async functions, and support is good enough now that I think we can solve it by adding a new top-level constructor td.asyncFunc and update imitate() to invoke that for all instances of AsyncFunction

This would resolve: #245 #371

cc/ @neall @jasonkarns

searls avatar May 21 '18 19:05 searls

Love the idea! 👍

jsardev avatar Aug 22 '18 09:08 jsardev

I'd love to see this as well! Something to consider is that I would expect mockAsyncFn[Symbol.toStringTag] to return "AsyncFunction" to allow full interoperability with how current versions Node.js tag async functions.

async function actualFn() {}

assert.equal(actualFn[Symbol.toStringTag], "AsyncFunction")

const mockFn = td.asyncFunction("mockFn")

assert.equal(mockFn[Symbol.toStringTag], "AsyncFunction")

sirlancelot avatar Jan 11 '21 22:01 sirlancelot

Stale. Closing. Please reopen if still relevant and I will look into it.

giltayar avatar Sep 16 '23 11:09 giltayar