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.

no-interpolation-in-snapshots.md 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`)
  2. Prevents the use of string interpolations in snapshots.
  3. ## Rule Details
  4. Interpolation prevents snapshots from being updated. Instead, properties should
  5. be overloaded with a matcher by using
  6. [property matchers](https://jestjs.io/docs/en/snapshot-testing#property-matchers).
  7. Examples of **incorrect** code for this rule:
  8. ```js
  9. expect(something).toMatchInlineSnapshot(
  10. `Object {
  11. property: ${interpolated}
  12. }`,
  13. );
  14. expect(something).toMatchInlineSnapshot(
  15. { other: expect.any(Number) },
  16. `Object {
  17. other: Any<Number>,
  18. property: ${interpolated}
  19. }`,
  20. );
  21. expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(
  22. `${interpolated}`,
  23. );
  24. ```
  25. Examples of **correct** code for this rule:
  26. ```js
  27. expect(something).toMatchInlineSnapshot();
  28. expect(something).toMatchInlineSnapshot(
  29. `Object {
  30. property: 1
  31. }`,
  32. );
  33. expect(something).toMatchInlineSnapshot(
  34. { property: expect.any(Date) },
  35. `Object {
  36. property: Any<Date>
  37. }`,
  38. );
  39. expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot();
  40. expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(
  41. `Error Message`,
  42. );
  43. ```
  44. ## When Not To Use It
  45. Don't use this rule on non-jest test files.