State.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import type { Config } from '@jest/types';
  8. import type { OptionsReceived as PrettyFormatOptions } from 'pretty-format';
  9. export declare type SnapshotStateOptions = {
  10. updateSnapshot: Config.SnapshotUpdateState;
  11. prettierPath: Config.Path;
  12. expand?: boolean;
  13. snapshotFormat: PrettyFormatOptions;
  14. };
  15. export declare type SnapshotMatchOptions = {
  16. testName: string;
  17. received: unknown;
  18. key?: string;
  19. inlineSnapshot?: string;
  20. isInline: boolean;
  21. error?: Error;
  22. };
  23. declare type SnapshotReturnOptions = {
  24. actual: string;
  25. count: number;
  26. expected?: string;
  27. key: string;
  28. pass: boolean;
  29. };
  30. declare type SaveStatus = {
  31. deleted: boolean;
  32. saved: boolean;
  33. };
  34. export default class SnapshotState {
  35. private _counters;
  36. private _dirty;
  37. private _index;
  38. private _updateSnapshot;
  39. private _snapshotData;
  40. private _initialData;
  41. private _snapshotPath;
  42. private _inlineSnapshots;
  43. private _uncheckedKeys;
  44. private _prettierPath;
  45. private _snapshotFormat;
  46. added: number;
  47. expand: boolean;
  48. matched: number;
  49. unmatched: number;
  50. updated: number;
  51. constructor(snapshotPath: Config.Path, options: SnapshotStateOptions);
  52. markSnapshotsAsCheckedForTest(testName: string): void;
  53. private _addSnapshot;
  54. clear(): void;
  55. save(): SaveStatus;
  56. getUncheckedCount(): number;
  57. getUncheckedKeys(): Array<string>;
  58. removeUncheckedKeys(): void;
  59. match({ testName, received, key, inlineSnapshot, isInline, error, }: SnapshotMatchOptions): SnapshotReturnOptions;
  60. fail(testName: string, _received: unknown, key?: string): string;
  61. }
  62. export {};