Put in order · NestJS course · Module 7: Testing

Assertions for rejected Promise

Arrange the steps for testing an asynchronous exception:

Items to put in order

  • Verify the exception type and message
  • Use expect().rejects.toThrow()
  • Call the async method under test
  • Configure the mock to throw an exception

You can check the correct answer by solving this task in the CodeWorlds game.