Skip to content

Conversation

@orthizar
Copy link
Contributor

Fixes #140
I implemented normalization of the prisma client output path before checking the ending against 'node_modules/@prisma/client'.

I am unsure how to go about creating the unit test, because it should mock the prismaClient.output?.value being in windows path style and running the onGenerate function.
Any ideas how to implement this unit test?

@franky47
Copy link
Member

franky47 commented Sep 25, 2025

Thanks!

Regarding tests, you could extract the whole path manipulation to a dedicated function, and test it with the various code paths it takes.

To get CI to pass, feel free to steal this line from PR https://github.com/47ng/prisma-field-encryption/pull/144/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fL27

@orthizar
Copy link
Contributor Author

The code has been moved into a separate file and wrapped in a function, so it can be tested in isolation.
I wrote unit tests for it instead of integration tests, since the tests don’t cover any integrations.

@franky47 franky47 added the deploy:preview Deploy a preview version of this PR on pkg.pr.new label Sep 25, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 25, 2025

npm i https://pkg.pr.new/prisma-field-encryption@146

commit: 50833ed

@franky47
Copy link
Member

The test is good, but it doesn't run, we need to modify the Jest config file to allow running nested tests (not just at the root of src):

"testMatch": ["<rootDir>/src/*.test.[jt]s?(x)"]

Feel free to use the pkg.pr.new link above to install a preview build in your app to see how it works on your end.

@orthizar
Copy link
Contributor Author

I updated the testMatch to include subdirectories, while ignoring the tests directory as these are integrations tests.

@Sumis34
Copy link

Sumis34 commented Sep 26, 2025

I tested it on Windows 11 and it has fixed the issue.

Before:

import type { PrismaClient, EnvironmentVariable } from '../D:\code\shiper\node_modules\.pnpm\@[email protected][email protected]\node_modules\@prisma\client'

With https://pkg.pr.new/prisma-field-encryption@146:

import type { PrismaClient, EnvironmentVariable } from '@prisma/client'

@franky47 franky47 merged commit 59f8668 into 47ng:next Sep 26, 2025
3 checks passed
@franky47
Copy link
Member

Thank you! I'll see if I can deploy this over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy:preview Deploy a preview version of this PR on pkg.pr.new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Path Issue in Generated Import Statements

3 participants