Question · NestJS course · Module 7: Testing
Handling exceptions in tests
To check if a method throws an exception, we use:
Answer options
- expect(method).toBe(Error)
- try/catch without assertions
- expect(() => method()).toThrow()
- assert.throws(method)
You can check the correct answer by solving this task in the CodeWorlds game.