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

Cannot find module 'nexus-prisma/scalars' when testing with jest #182

Open
zaniluca opened this issue Jan 18, 2022 · 1 comment
Open

Cannot find module 'nexus-prisma/scalars' when testing with jest #182

zaniluca opened this issue Jan 18, 2022 · 1 comment
Labels
type/bug Something is not working the way it should

Comments

@zaniluca
Copy link

Screenshot

Screenshot

Description

Trying to test my schema i get this error from the nexus-prisma/scalars module.
I'm using nexus nexus-prisma and apollo-server-express and I'm testing with jest and ts-jest

Versions:
"dependencies": {
    "@prisma/client": "^3.7.0",
    "apollo-server-express": "^3.6.1"
    "express": "^4.17.2"
    "graphql": "^14.5.0",
    "nexus": "^1.1.0",
    "nexus-prisma": "^0.35.0"
  },
  "devDependencies": {
    "@types/express": "^4.17.13",
    "@types/graphql": "^14.5.0",
    "@types/jest": "^27.4.0",
    "@types/node": "^17.0.8",
    "@types/supertest": "^2.0.11",
    "jest": "^27.4.7",
    "nodemon": "^2.0.15",
    "prisma": "^3.7.0",
    "supertest": "^6.2.1",
    "ts-jest": "^27.1.3",
    "ts-node": "^10.4.0"
    "typescript": "^4.5.4"
  }

Here is my schema.ts file

import { join } from "path";
import * as types from "./definitions";
import { makeSchema } from "nexus";
import { DateTime } from "nexus-prisma/scalars";

export const schema = makeSchema({
  // `NexusPrismaScalars` is for supporting the `DateTime` type
  types: [types, DateTime],
  // Where the generated files are placed
  outputs: {
    typegen: join(__dirname, "node_modules/@types/nexus-typegen/index.d.ts"),
    schema: join(__dirname, "./schema.graphql"),
  },
  sourceTypes: {
    modules: [{ module: ".prisma/client", alias: "PrismaClient" }],
  },
  contextType: {
    module: join(__dirname, "context.ts"),
    export: "Context",
  },
});

And this is my jest.config.js

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
  preset: "ts-jest",
  testEnvironment: "node",
  moduleDirectories: ["node_modules", "src"],
};

Repro Steps/Link

-Make any nexus-prisma project that has NexusPrismaScalars in types array.
-run tests with jest

@zaniluca zaniluca added the type/bug Something is not working the way it should label Jan 18, 2022
@HaKePlan
Copy link

Is there any solution to that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working the way it should
Projects
None yet
Development

No branches or pull requests

2 participants