From c30346cf5dec0aa943d8abcdc436c53cd1ef49e3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 30 Sep 2022 00:25:28 -0700 Subject: Create test_scope_debug.ts --- test/bun.js/test_scope_debug.ts | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test/bun.js/test_scope_debug.ts (limited to 'test/bun.js/test_scope_debug.ts') diff --git a/test/bun.js/test_scope_debug.ts b/test/bun.js/test_scope_debug.ts new file mode 100644 index 000000000..c1bb6c9fa --- /dev/null +++ b/test/bun.js/test_scope_debug.ts @@ -0,0 +1,62 @@ +export function wrap({ test: test_, it: it_, describe: describe_ }) { + if (it_ === undefined) { + it_ = test_; + } + + var describe = (label, cb) => { + return describe_( + label, + cb instanceof async function () {}.constructor + ? async () => { + console.log(`DESCRIBE [Enter] ${label}`); + try { + return await cb(); + } catch (e) { + throw e; + } finally { + console.log(`DESCRIBE [Exit] ${label}`); + } + } + : () => { + console.log(`DESCRIBE [Enter] ${label}`); + try { + return cb(); + } catch (e) { + throw e; + } finally { + console.log(`DESCRIBE [Exit] ${label}`); + } + } + ); + }; + + var it = (label, cb) => { + console.log("Before", label); + return it_( + label, + cb instanceof async function () {}.constructor + ? async () => { + console.log(`TEST [Enter] ${label}`); + try { + return await cb(); + } catch (e) { + throw e; + } finally { + console.log(`TEST [Exit] ${label}`); + } + } + : () => { + console.log(`TEST [Enter] ${label}`); + try { + return cb(); + } catch (e) { + throw e; + } finally { + console.log(`TEST [Exit] ${label}`); + } + } + ); + }; + + return { describe, it }; +} -- cgit v1.2.3