Skip to content

Unit Testing guide's with-singleton.ts tests fail to run #4560

Description

@Kelamir

Hello, I followed the following tutorial through: https://www.prisma.io/docs/guides/testing/unit-testing with Singleton approach, having replicated files with_singleton.ts, singleton.ts, functions-without-context.ts and followed the setup through. After npm run test, the following error is displayed:


 FAIL  __tests__/with_singleton.ts
  ● Test suite failed to run

    __tests__/with_singleton.ts:29:44 - error TS2345: Argument of type '{ id: number; name: string; email: string; }' is not assignable to parameter of type 'User | Prisma__UserClient<User, never>'.
      Property 'acceptTermsAndConditions' is missing in type '{ id: number; name: string; email: string; }' but required in type 'User'.

    29   prismaMock.user.update.mockResolvedValue(user)
                                                  ~~~~

      node_modules/.prisma/client/index.d.ts:21:3
        21   acceptTermsAndConditions: boolean
             ~~~~~~~~~~~~~~~~~~~~~~~~
        'acceptTermsAndConditions' is declared here.

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.223 s

The document in question is https://github.com/prisma/docs/blob/main/content/300-guides/150-testing/100-unit-testing.mdx

Metadata

Metadata

Assignees

Labels

type/docsDocumentation creation, updates or corrections

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions