Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

require-to-throw-message.md 1023B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Require a message for `toThrow()` (`require-to-throw-message`)
  2. `toThrow()` (and its alias `toThrowError()`) is used to check if an error is
  3. thrown by a function call, such as in `expect(() => a()).toThrow()`. However, if
  4. no message is defined, then the test will pass for any thrown error. Requiring a
  5. message ensures that the intended error is thrown.
  6. ## Rule details
  7. This rule triggers a warning if `toThrow()` or `toThrowError()` is used without
  8. an error message.
  9. ### Default configuration
  10. The following patterns are considered warnings:
  11. ```js
  12. test('all the things', async () => {
  13. expect(() => a()).toThrow();
  14. expect(() => a()).toThrowError();
  15. await expect(a()).rejects.toThrow();
  16. await expect(a()).rejects.toThrowError();
  17. });
  18. ```
  19. The following patterns are not considered warnings:
  20. ```js
  21. test('all the things', async () => {
  22. expect(() => a()).toThrow('a');
  23. expect(() => a()).toThrowError('a');
  24. await expect(a()).rejects.toThrow('a');
  25. await expect(a()).rejects.toThrowError('a');
  26. });
  27. ```