aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/test_scope_debug.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-12 17:47:05 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-12 17:47:05 -0700
commitec00838a03c809157b42cc8d006c95f9a5757163 (patch)
tree3735fcd05dfb724727d26e9d414f530bf1f3dd2b /test/bun.js/test_scope_debug.ts
parent860bd53fb3c652c65ea6c67df32d8f93e13982d6 (diff)
downloadbun-ec00838a03c809157b42cc8d006c95f9a5757163.tar.gz
bun-ec00838a03c809157b42cc8d006c95f9a5757163.tar.zst
bun-ec00838a03c809157b42cc8d006c95f9a5757163.zip
Update test_scope_debug.ts
Diffstat (limited to 'test/bun.js/test_scope_debug.ts')
-rw-r--r--test/bun.js/test_scope_debug.ts113
1 files changed, 111 insertions, 2 deletions
diff --git a/test/bun.js/test_scope_debug.ts b/test/bun.js/test_scope_debug.ts
index c1bb6c9fa..9af649552 100644
--- a/test/bun.js/test_scope_debug.ts
+++ b/test/bun.js/test_scope_debug.ts
@@ -1,4 +1,12 @@
-export function wrap({ test: test_, it: it_, describe: describe_ }) {
+export function wrap({
+ test: test_,
+ it: it_,
+ describe: describe_,
+ beforeEach: beforeEach_ = undefined,
+ beforeAll: beforeAll_ = undefined,
+ afterEach: afterEach_ = undefined,
+ afterAll: afterAll_ = undefined,
+}) {
if (it_ === undefined) {
it_ = test_;
}
@@ -58,5 +66,106 @@ export function wrap({ test: test_, it: it_, describe: describe_ }) {
);
};
- return { describe, it };
+ var beforeEach = (cb) => {
+ return beforeEach_(
+ cb instanceof async function () {}.constructor
+ ? async () => {
+ console.log(`BEFORE EACH [Enter]`);
+ try {
+ return await cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`BEFORE EACH [Exit]`);
+ }
+ }
+ : () => {
+ console.log(`BEFORE EACH [Enter]`);
+ try {
+ return cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`BEFORE EACH [Exit]`);
+ }
+ }
+ );
+ };
+ var beforeAll = (cb) => {
+ return beforeAll_(
+ cb instanceof async function () {}.constructor
+ ? async () => {
+ console.log(`BEFORE ALL [Enter]`);
+ try {
+ return await cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`BEFORE ALL [Exit]`);
+ }
+ }
+ : () => {
+ console.log(`BEFORE ALL [Enter]`);
+ try {
+ return cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`BEFORE ALL [Exit]`);
+ }
+ }
+ );
+ };
+ var afterEach = (cb) => {
+ return afterEach_(
+ cb instanceof async function () {}.constructor
+ ? async () => {
+ console.log(`AFTER EACH [Enter]`);
+ try {
+ return await cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`AFTER EACH [Exit]`);
+ }
+ }
+ : () => {
+ console.log(`AFTER EACH [Enter]`);
+ try {
+ return cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`AFTER EACH [Exit]`);
+ }
+ }
+ );
+ };
+ var afterAll = (cb) => {
+ return afterAll_(
+ cb instanceof async function () {}.constructor
+ ? async () => {
+ console.log(`AFTER ALL [Enter]`);
+ try {
+ return await cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`AFTER ALL [Exit]`);
+ }
+ }
+ : () => {
+ console.log(`AFTER ALL [Enter]`);
+ try {
+ return cb();
+ } catch (e) {
+ throw e;
+ } finally {
+ console.log(`AFTER ALL [Exit]`);
+ }
+ }
+ );
+ };
+
+ return { describe, it, beforeEach, beforeAll, afterEach, afterAll };
}