From bf518222d456c913fc5e6b6e0d14952d76c0ce91 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 9 Jun 2023 16:38:06 -0700 Subject: Implement mocks in bun:test (#3252) * wip * wip * most of the code for mocks in bun:test * finishing up * Implement `toHaveBeenCalled` and `toHaveBeenCalledTimes(1)` * Test * visit * results, not returnValues * exact * Update jest.zig * A couple more tests * Add jest.fn * support resetting mocks * Implement spyOn --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_parser.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/js_parser.zig') diff --git a/src/js_parser.zig b/src/js_parser.zig index 5f46507d7..5dc69f469 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -4674,6 +4674,7 @@ const Jest = struct { afterEach: Ref = Ref.None, beforeAll: Ref = Ref.None, afterAll: Ref = Ref.None, + jest: Ref = Ref.None, }; // workaround for https://github.com/ziglang/zig/issues/10903 @@ -6474,6 +6475,7 @@ fn NewParser_( if (p.options.features.inject_jest_globals) { p.jest.describe = try p.declareCommonJSSymbol(.unbound, "describe"); p.jest.@"test" = try p.declareCommonJSSymbol(.unbound, "test"); + p.jest.jest = try p.declareCommonJSSymbol(.unbound, "jest"); p.jest.it = try p.declareCommonJSSymbol(.unbound, "it"); p.jest.expect = try p.declareCommonJSSymbol(.unbound, "expect"); p.jest.beforeEach = try p.declareCommonJSSymbol(.unbound, "beforeEach"); -- cgit v1.2.3