prisma-factory icon indicating copy to clipboard operation
prisma-factory copied to clipboard

ENOENT when trying to use generated functions with Jest

Open zacwebb opened this issue 2 years ago • 9 comments

Hey there,

Thanks for the work on this package - looks great! 😁

Any chance you'd know why Jest is struggling to find the generated index.js? I get the following error: ENOENT: no such file or directory, open '/{path to code}/node_modules/prisma-factory/dist/generated.js'

Example of my code:

import { createUserFactory } from 'prisma-factory/generated';

export const UserFactory = createUserFactory({
    email: '[email protected]',
    password: '123',
    verified: true,
});

I've checked that the generated code is there inside node_modules – not sure if this is an issue with my jest/typescript config or a package issue?

Thanks again

zacwebb avatar Aug 08 '22 11:08 zacwebb

Have you resolved it ?

terrarium789 avatar Sep 17 '22 16:09 terrarium789

Just a bump up to share that it's still going on. Happening on Turborepo monorepo. Cannot find module '/Users/lea/dev/app/node_modules/prisma-factory/dist/generated/index.js

Basically in the node_modules the dist/generated/index.js can not be seen: image

leandrit1 avatar Jan 17 '23 11:01 leandrit1

Any resolution on this ?

Mozartted avatar Jan 19 '23 02:01 Mozartted

I'm experiencing the same issue

AlextheYounga avatar Mar 23 '23 03:03 AlextheYounga

I tried adding a dummy file there but it did not work out for me. node_modules/prisma-factory/dist/generated.js

module.exports = {};

seems like some build artifact is missing? Has anyone been able to workaround this?

adityaguru149 avatar Apr 14 '23 15:04 adityaguru149

Hi all, I've solved the problem here #25

fech-dev avatar Jun 07 '23 08:06 fech-dev

Is there any workaround for this? I'd really love to use this package!

marvin-wtt avatar Jun 14 '23 23:06 marvin-wtt

Is there any workaround for this? I'd really love to use this package!

Unfortunately there aren't any workaround.... I've solved the problem with this pr #25, but it seems it is not merged yet...

fech-dev avatar Jun 15 '23 06:06 fech-dev

I actually found a working solution for me. Just move the generated output to a local directory.

generator factories {
  provider = "prisma-factory"
  output   = "./generated"
}

I still have a problem because the path to the client is not escaped for Windws OS but that's a different issue

marvin-wtt avatar Jun 22 '23 00:06 marvin-wtt