How do egg unit tests test assert statements?

egg application. A function is as follows:

function abc(arg) {
    assert(typeof arg === "string", "arg should be a string");
    
    // do other thing
    // ...
}

if the parameter is of non-string type, the assert statement will be triggered and the console will report an error. In the test case, how to write the console so as not to report an error?

it("should call abc(1) fail", () => {
    // how
});
Jun.18,2022

try {
  abc(arg);
} catch (err) {
  if (err instanceof AssertionError) {
    // 
    return
  }
}

// 

General testing frameworks have test assertion methods for exceptions. Anyway, to do it yourself is to try cache to judge

.
console.assert
Menu