Giter Site home page Giter Site logo

Comments (10)

connectdotz avatar connectdotz commented on June 15, 2024

@SimenB do you object we re-expose these functions/types?

from jest.

mrazauskas avatar mrazauskas commented on June 15, 2024

Perhaps the utils could simply be published as separate @jest/snapshot-utils package?

from jest.

connectdotz avatar connectdotz commented on June 15, 2024

I'm ok with either approach. @SimenB, what's your take?

from jest.

SimenB avatar SimenB commented on June 15, 2024

Separate util package makes sense to me 👍 Happy to take a PR to that effect 🙂

from jest.

connectdotz avatar connectdotz commented on June 15, 2024

@SimenB, a few follow-up questions regarding splitting the utils into its own package @jest/snapshot-utils:

Circular Reference

Is it correct to assume that you would prefer the @jest/snapshot-utils package not to depend on the @jest/snapshot package due to circular reference? If that is the case, we have the following dependency issues to resolve:

In utils.ts:

import {getSerializers} from './plugins';
import type {SnapshotData} from './types';
  • The ./plugins module is not used anywhere except in utils.ts. Should we move it to @jest/snapshot-utils as well?
  • The type SnapshotData from ./types is simply a Record<string, string>. Do we want to create a new package @jest/snapshot-types for a single line type definition? Or maybe the whole ./types file?

Re-evaluation

Given these issues, do we still favor splitting utils.ts into new packages (@jest/snapshot-utils, @jest/snapshot-types) over exposing it within @jest/snapshot?

from jest.

mrazauskas avatar mrazauskas commented on June 15, 2024

In TypeScript repo they have public and internal utilities. Perhaps similar strategy could be adopted? I mean, the new package could exposing only getSnapshotData(), testNameToKey() and other actually useful utilities not all what utils.ts contains.

By the way, I think SnapshotData can be replaced with Record<string, string>. That looks fine, because TypeScript does not have nominal types.

UPDATE: Or SnapshotData could be exported from the new package, because it is part of the return type of getSnapshotData().

from jest.

SimenB avatar SimenB commented on June 15, 2024

Moving SnapshotData to the new package should be fine, yeah

from jest.

connectdotz avatar connectdotz commented on June 15, 2024

sorry for the delay, I am back to this issue now. One more question, given the jest-snapshot doesn't use the "@jest" scope (not sure what the naming rule is), do we want the new package to be @jest/snapshot-utils or jest-snapshot-utils?

from jest.

SimenB avatar SimenB commented on June 15, 2024

The old ones don't as they predate our ownership of the jest org on NPM. All new packages should use the namescaped one, but we don't wanna migrate old ones (just to avoid dependents getting left behind).

from jest.

SimenB avatar SimenB commented on June 15, 2024

https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.5

from jest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.