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

test(cli): add prismaSchemaFolder-specific tests #24141

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented May 9, 2024

WIP

This PR closes https://github.com/prisma/team-orm/issues/1137.
It adds test cases to:

  • packages/cli
    • validate
    • format
    • generate
  • packages/internals
    • getDmmf
    • getConfig
    • getSchema

This PR also adds a new tree() utility to jestContext, which provides a JavaScript-friendly implementation of the tree UNIX command. It returns a string showcasing the file and directory structure starting from the fixture root directory:

import { jestContext } from '@prisma/get-platform'

const ctx = jestContext.new().assemble()

describe('validate', () => {
  it('some test using fixtures with many files and folders', () => {
    ctx.fixture('multi-schema-files/valid')
    expect(ctx.tree()).toMatchInlineSnapshot(`
      "
      └── prisma/
          └── schema/
              └── schema1.prisma
              └── schema2.prisma
          └── custom.prisma
          └── schema.prisma
      └── custom.prisma
      └── schema.prisma
      "
    `)
  })
})

The prismaSchemaFolder preview feature, which allows reading multiple schema files at once and combine them as a single schema, heavily relies on the file disk structure. This ctx.tree() utility allows to snapshot the disk structure in the tests, allowing easy future reference for Prisma developers.

Copy link
Contributor

github-actions bot commented May 9, 2024

size-limit report 📦

Path Size
packages/client/runtime/library.js 179.77 KB (0%)
packages/client/runtime/library.d.ts 81 B (0%)
packages/client/runtime/binary.js 600.89 KB (0%)
packages/client/runtime/binary.d.ts 26 B (0%)
packages/client/runtime/edge.js 159.02 KB (0%)
packages/client/runtime/edge-esm.js 158.91 KB (0%)
packages/client/runtime/wasm.js 114.85 KB (0%)
packages/client/runtime/index-browser.js 33.77 KB (0%)
packages/client/runtime/index-browser.d.ts 89 B (0%)
packages/cli/build/index.js 2.09 MB (+0.01% 🔺)
packages/client/prisma-client-0.0.0.tgz 3.02 MB (0%)
packages/cli/prisma-0.0.0.tgz 3.74 MB (+0.01% 🔺)
packages/bundle-size/da-workers-libsql/output.tgz 888.14 KB (0%)
packages/bundle-size/da-workers-neon/output.tgz 966.74 KB (0%)
packages/bundle-size/da-workers-pg/output.tgz 985.47 KB (0%)
packages/bundle-size/da-workers-pg-worker/output.tgz 941.18 KB (0%)
packages/bundle-size/da-workers-planetscale/output.tgz 903.56 KB (0%)
packages/bundle-size/da-workers-d1/output.tgz 861.2 KB (0%)

@jkomyno jkomyno self-assigned this May 9, 2024
@jkomyno jkomyno added this to the 5.14.0 milestone May 9, 2024
Copy link

codspeed-hq bot commented May 9, 2024

CodSpeed Performance Report

Merging #24141 will improve performances by 23.7%

Comparing feat/test-prismaSchemaFolder (8130b96) with main (23aba0b)

Summary

⚡ 1 improvements
✅ 2 untouched benchmarks

Benchmarks breakdown

Benchmark main feat/test-prismaSchemaFolder Change
client generation 100 models with relations 40.7 s 32.9 s +23.7%

@jkomyno jkomyno modified the milestones: 5.14.0, 5.15.0 May 13, 2024
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

Successfully merging this pull request may close these issues.

None yet

1 participant