GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — feat(cli): warn on mismatch of global and local versions upon generate command by akhill10 · Pull Request #20951 · prisma/orm Conversation
|
|
@jharrell Thanks for the feedback. Updated the PR with the requested changes.
https://www.loom.com/share/6c2def1c11164690a314dc456182c466?sid=138bb99a-8e3e-4332-adfe-27e8933872b1
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @jharrell, did you get a chance to look at this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@akhill10 thank you very much for the loom video and apologies for the delay on my end! For this case, I think you should only test what is needed. That is to say, mock the results of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@jharrell I tried mocking the functions but result is not giving the mocked results in the //imports import { Generate, getLocalPrismaVersion } from '../../Generate' import { getInstalledPrismaClientVersion } from '../../utils/getClientVersion' it('should warn on mismatch of global version and local client version', async () => { ctx.fixture('example-project') const versions = { getInstalledPrismaClientVersion, isCurrentBinInstalledGlobally, getLocalPrismaVersion } jest.spyOn(versions, 'getInstalledPrismaClientVersion').mockReturnValue(Promise.resolve('0.0.1')) jest.spyOn(versions, 'isCurrentBinInstalledGlobally').mockReturnValue('npm') jest.spyOn(versions, 'getLocalPrismaVersion').mockReturnValue(Promise.resolve('0.0.2')) const data = await ctx.cli('generate') expect(data.stdout).toMatchInlineSnapshot(`warn: Global [email protected] and Local @prisma/[email protected] don't match. This might lead to unexpected behavior. Would you like to proceed ? [yes/no]`) }); Its still getting the example-project version value i.e |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@akhill10 I'm not sure. Please push your changes to this branch so that I can review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@jharrell Pushed the test case commit. Please take a look |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hello @jharrell , did you get a chance to review this? am I doing anything wrong in mocking the functions ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Have you tried using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah, I did but no luck. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Unfortunately, I'm not sure here. We'll need a way to mock these calls before we move forward. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Okay thank you, I try will some alternative approaches. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @akhill10, It looks like there haven't been any updates since @jharrell's last message to you. I'm closing this PR for now as part of our ongoing efforts to reduce the number of open issues and PRs in the repo. If you feel like this is a mistake, feel free to reopen the PR and address the comments :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fixes prisma#1911 When using a globally installed prisma CLI with a different local @prisma/client or prisma version, users will now see a warning message. Implementation: - Added versionMismatchChecker.ts with dependency injection for testability - Modified Generate.ts to check version mismatch before running generate - Added comprehensive test suite (11 tests, all passing) The solution uses dependency injection to make the version checking functions mockable in tests, addressing the issue from the previous attempt in PR prisma#20951 where jest.spyOn could not properly mock the module-level functions.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Warn on mismatch between globalprisma and local prisma or @prisma/client
There was an error while loading. Please reload this page.