refactor(tests): replace deprecated `toThrow` with `toThrowWith`

Closes #1425