eslint-plugin-misc

ESLint plugin

This project is maintained by iliubinskii

jest/no-toThrow-literal

ESLint plugin / jest/no-toThrow-literal

Disallows string argument in “toThrow” matcher.

module.exports = {
  plugins: ["misc"],
  rules: {
    "misc/jest/no-toThrow-literal": "error"
  }
};

Examples of incorrect code

expect(f).toThrow("Error message");

Examples of correct code

expect(f).toThrow(new Error("Error message"));