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

bug: cannot run trpc jest test with dependencies to other packages in monorepo #762

Open
fddayan opened this issue Nov 21, 2023 · 0 comments

Comments

@fddayan
Copy link

fddayan commented Nov 21, 2023

Provide environment information

System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 98.86 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
pnpm: 8.8.0 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
Watchman: 2023.08.28.00 - /opt/homebrew/bin/watchman

Describe the bug

I'm trying to setup ts-jest to run some test with tRPC procedures.

A test might look like:

describe("quote", () => {
  test("should return quote", async () => {
    const caller = onboardingRouter.createCaller(EMPTY_CONTEXT);

    await caller.onboardingForm.upsert({
     ...
    });
    ....
  });
});

I'm getting Cannot find module '@auth/core/providers/google' from '../auth/index.ts'

Long error:

 FAIL  src/router/onboarding/__test__/index.test.ts
  ● Test suite failed to run

    Cannot find module '@auth/core/providers/google' from '../auth/index.ts'

    Require stack:
      /Users/federicodayan/projects/com/pearl/pearl-turbo/packages/auth/index.ts
      src/trpc.ts
      src/router/onboarding/index.ts
      src/router/onboarding/__test__/index.test.ts

    > 1 | import GoogleProvider from "@auth/core/providers/google";
        | ^
      2 | import type { DefaultSession } from "@auth/core/types";
      3 | import { PrismaAdapter } from "@next-auth/prisma-adapter";
      4 | import NextAuth from "next-auth";

      at Resolver._throwModNotFoundError (../../node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (../auth/index.ts:1:1)
      at Object.<anonymous> (src/trpc.ts:13:1)
      at Object.<anonymous> (src/router/onboarding/index.ts:1:1)
      at Object.<anonymous> (src/router/onboarding/__test__/index.test.ts:5:1)

Link to reproduction

It's private code cannot share

To reproduce

  • install setup ts-jest
  • Try to test a tRPC endpoint

Additional information

No response

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