mochiya98 / mocha-chai-jest-snapshot

provides snapshot testing like jest
MIT License
29 stars 5 forks source link

Cannot find name 'SnapshotStateOptions' #15

Closed Maxim-Mazurok closed 3 months ago

Maxim-Mazurok commented 2 years ago

Getting this error when running tsc, with "skipLibCheck": false

node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts:14:58 - error TS2304: Cannot find name 'SnapshotStateOptions'.

14 export declare const makeEmptySnapshotSummary: (options: SnapshotStateOptions) => SnapshotSummary;
                                                            ~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts:14
Maxim-Mazurok commented 2 years ago

To fix this, I had to add these two patches:

mocha-chai-jest-snapshot+1.1.4.patch:

diff --git a/node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts b/node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts
index 7ce132e..2453da2 100644
--- a/node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts
+++ b/node_modules/mocha-chai-jest-snapshot/dist/utils/jest-test-result-helper.d.ts
@@ -5,7 +5,7 @@
  * LICENSE file in the root directory of this source tree.
  */
 import { SnapshotSummary, TestResult } from "@jest/test-result";
-import { SnapshotState } from "jest-snapshot";
+import { SnapshotState, SnapshotStateOptions } from "jest-snapshot";
 declare type SnapshotResult = TestResult["snapshot"];
 export { SnapshotSummary };
 export declare const makeEmptySnapshotSummary: (options: SnapshotStateOptions) => SnapshotSummary;

and mocha-chai-jest-snapshot++jest-snapshot+28.1.3.patch:

diff --git a/node_modules/mocha-chai-jest-snapshot/node_modules/jest-snapshot/build/index.d.ts b/node_modules/mocha-chai-jest-snapshot/node_modules/jest-snapshot/build/index.d.ts
index 3f20807..b47c90a 100644
--- a/node_modules/mocha-chai-jest-snapshot/node_modules/jest-snapshot/build/index.d.ts
+++ b/node_modules/mocha-chai-jest-snapshot/node_modules/jest-snapshot/build/index.d.ts
@@ -148,7 +148,7 @@ export declare class SnapshotState {
   fail(testName: string, _received: unknown, key?: string): string;
 }

-declare type SnapshotStateOptions = {
+export declare type SnapshotStateOptions = {
   updateSnapshot: Config.SnapshotUpdateState;
   prettierPath: string;
   expand?: boolean;

using https://www.npmjs.com/package/patch-package

rostalevicek commented 1 year ago

Is it possible to merge this patch?

Maxim-Mazurok commented 1 year ago

Is it possible to merge this patch?

I've created a PR with alternative fix: https://github.com/mochiya98/mocha-chai-jest-snapshot/pull/19