diff options
author | 2022-09-30 00:25:28 -0700 | |
---|---|---|
committer | 2022-09-30 00:25:28 -0700 | |
commit | c30346cf5dec0aa943d8abcdc436c53cd1ef49e3 (patch) | |
tree | e769b20dac0971b5692c219984503be2154c4bcf /test/bun.js/test_scope_debug.ts | |
parent | 64ef2389dcedac599b131165c27929143131e937 (diff) | |
download | bun-c30346cf5dec0aa943d8abcdc436c53cd1ef49e3.tar.gz bun-c30346cf5dec0aa943d8abcdc436c53cd1ef49e3.tar.zst bun-c30346cf5dec0aa943d8abcdc436c53cd1ef49e3.zip |
Create test_scope_debug.ts
Diffstat (limited to 'test/bun.js/test_scope_debug.ts')
-rw-r--r-- | test/bun.js/test_scope_debug.ts | 62 |
1 files changed, 62 insertions, 0 deletions
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 }; +} |