Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument of type <string> is not assignable to parameter of type... #40

Closed
cahlan opened this issue Feb 28, 2023 · 1 comment
Closed

Comments

@cahlan
Copy link

cahlan commented Feb 28, 2023

I'm excited about using this library, and I'm suspecting it's some configuration that's causing me headaches. But I have a 3rd party library (airtable) that I am trying to stub for testing purposes. Below is my simplified code:

import { ImportMock } from "ts-mock-imports";
import Airtable from "airtable";

const airtableMock = ImportMock.mockClass(Airtable, "Airtable");
const stub = airtableMock.mock("destroy");

I keep getting the following errors for the mockClass and the mock functions:

error TS2345: Argument of type '"Airtable"' is not assignable to parameter of type '"prototype" | "Base" | "Record" | "Table" | "Error" | "apiKey" | "apiVersion" | "endpointUrl" | "noRetryIfRateLimited" | "requestTimeout" | "default_config" | "configure" | "base" | undefined'.

8 const airtableMock = ImportMock.mockClass(Airtable, "Airtable");
error TS2345: Argument of type '"destroy"' is not assignable to parameter of type '"prototype" | "Base" | "Record" | "Table" | "Error" | "apiKey" | "apiVersion" | "endpointUrl" | "noRetryIfRateLimited" | "requestTimeout" | "default_config" | "configure" | "base" | undefined'.

8 ImportMock.mockFunction(Airtable, "destroy");
@cahlan
Copy link
Author

cahlan commented Mar 1, 2023

Closing as I realized it was a problem in the way I was trying to mock the class/function. Didn't understand the process well enough. After reading through the docs and source code, I think I'm on the right track.

@cahlan cahlan closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant