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

Snapshot serializer in CLI tests doesn't replace time durations >= 1s with a placeholder #10896

Closed
aqrln opened this issue Dec 29, 2021 · 4 comments
Labels
kind/tech A technical change. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: internal topic: tests
Milestone

Comments

@aqrln
Copy link
Member

aqrln commented Dec 29, 2021

Snapshot serializer in CLI tests doesn't replace time durations greater than or equal to 1s with a placeholder.

Failed pipeline: https://github.com/prisma/prisma/runs/4657927865?check_suite_focus=true#step:15:662

  ● --schema from parent directory › --schema absolute path: should work

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `--schema from parent directory --schema absolute path: should work 1`

    - Snapshot  - 1
    + Received  + 1

      ↵
    - ✔ Generated Prisma Client (0.0.0 | TEST_ENGINE_TYPE) to ./subdirectory/@prisma/client in XXms
    + ✔ Generated Prisma Client (0.0.0 | TEST_ENGINE_TYPE) to ./subdirectory/@prisma/client in 3.34s
      You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

Relevant code:

function normalizeMs(str) {
return str.replace(/\d{1,3}ms/g, 'XXms')
}

@janpio janpio added kind/tech A technical change. team/client Issue for team Client. labels Dec 29, 2021
@Jolg42
Copy link
Member

Jolg42 commented Jan 13, 2022

It does now so I'll close

https://github.com/prisma/prisma/blob/main/packages/sdk/src/utils/jestSnapshotSerializer.js#L74

@Jolg42 Jolg42 closed this as completed Jan 13, 2022
@aqrln
Copy link
Member Author

aqrln commented Jan 13, 2022

Thanks!

@aqrln
Copy link
Member Author

aqrln commented Jan 13, 2022

return str.replace(/ \d+ms/g, ' XXXms').replace(/ \d+(.\d+)?s/g, ' XXXms')

. needs to be escaped here

> / \d+(.\d+)?s/.test(' 3a3s')
true

@Jolg42
Copy link
Member

Jolg42 commented Jan 13, 2022

Thanks! added in #11123

@Jolg42 Jolg42 added this to the 3.9.0 milestone Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/tech A technical change. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: internal topic: tests
Projects
None yet
Development

No branches or pull requests

3 participants