Files
ai-course/node_modules/eslint-plugin-jest/docs/rules/require-to-throw-message.md
KQL ce6aa207e9 fix: 修复图片路径以适配GitHub Pages base path
- 将所有图片路径从绝对路径改为使用 process.env.PUBLIC_URL
- 修复 HomePage.tsx 中所有图片引用
- 修复 CoursePage.tsx 中所有图片引用
- 确保图片在 GitHub Pages 上正确加载

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 09:24:45 +08:00

1023 B

Require a message for toThrow() (require-to-throw-message)

toThrow() (and its alias toThrowError()) is used to check if an error is thrown by a function call, such as in expect(() => a()).toThrow(). However, if no message is defined, then the test will pass for any thrown error. Requiring a message ensures that the intended error is thrown.

Rule details

This rule triggers a warning if toThrow() or toThrowError() is used without an error message.

Default configuration

The following patterns are considered warnings:

test('all the things', async () => {
  expect(() => a()).toThrow();

  expect(() => a()).toThrowError();

  await expect(a()).rejects.toThrow();

  await expect(a()).rejects.toThrowError();
});

The following patterns are not considered warnings:

test('all the things', async () => {
  expect(() => a()).toThrow('a');

  expect(() => a()).toThrowError('a');

  await expect(a()).rejects.toThrow('a');

  await expect(a()).rejects.toThrowError('a');
});