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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be48f9-316ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be48f9-316ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?