diff --git a/modules/llrt_assert/src/lib.rs b/modules/llrt_assert/src/lib.rs index 491cf352ce..501f5e8934 100644 --- a/modules/llrt_assert/src/lib.rs +++ b/modules/llrt_assert/src/lib.rs @@ -24,7 +24,13 @@ fn ok(ctx: Ctx, value: Value, message: Opt) -> Result<()> { return Ok(()); } }, - Type::Array | Type::Object => { + Type::Array + | Type::BigInt + | Type::Constructor + | Type::Exception + | Type::Function + | Type::Symbol + | Type::Object => { return Ok(()); }, _ => {}, @@ -43,7 +49,7 @@ fn ok(ctx: Ctx, value: Value, message: Opt) -> Result<()> { Err(Exception::throw_message( &ctx, - "The expression was evaluated to a falsy value", + "AssertionError: The expression was evaluated to a falsy value", )) } diff --git a/tests/unit/assert.test.ts b/tests/unit/assert.test.ts index a4cfd08442..14bf2eb3d0 100644 --- a/tests/unit/assert.test.ts +++ b/tests/unit/assert.test.ts @@ -2,15 +2,22 @@ import assert from "assert"; describe("assert.ok", () => { it("Should be returned 'undefined' (So it's not an error)", () => { - expect(assert.ok(true)).toBeUndefined(); - expect(assert.ok(1)).toBeUndefined(); - expect(assert.ok("non-empty string")).toBeUndefined(); - expect(assert.ok([])).toBeUndefined(); - expect(assert.ok({})).toBeUndefined(); + expect(assert.ok(true)).toBeUndefined(); //bool + expect(assert.ok(1)).toBeUndefined(); // numeric + expect(assert.ok("non-empty string")).toBeUndefined(); // string + expect(assert.ok([])).toBeUndefined(); // array + expect(assert.ok({})).toBeUndefined(); // object + expect(assert.ok(() => {})).toBeUndefined(); // function + expect(assert.ok(123n)).toBeUndefined(); // bigint + expect(assert.ok(Symbol())).toBeUndefined(); // symbol + expect(assert.ok(new Error())).toBeUndefined(); // error + class AssertTestClass {} + expect(assert.ok(AssertTestClass)).toBeUndefined(); // constructor }); it("Should be returned exception", () => { - const errMsg = "The expression was evaluated to a falsy value"; + const errMsg = + "AssertionError: The expression was evaluated to a falsy value"; try { assert.ok(false); } catch (err) {