I am new to jest and testing with typescript. I am having the above error in one of my test files. I searched a lot but couldn't find either the reason or the problem. I have other test files with the same value object id:expect.any(String) but they have no error.
Here are the sample files:
branchDetail.ts
export interface BranchDetailsModel {
id: string;
brandId: string;
name?: string;
address?: string;
employeeName?: string;
position?: string;
mobileNumber?: string;
}
brand.spec.ts
...
const testBranchDetail: BranchDetailsModel = {
id: expect.any(String), //Type 'AsymmetricMatcher' is not assignable to type 'string'.
brandId: '',
address: 'address',
employeeName: 'sample',
mobileNumber: 'sample',
position: 'sample',
};