Search code examples
javascriptreactjsnpmjestjssemantic-versioning

If I update a react module such that existing code functions but Jest snapshot tests may break, should that be a major version bump?


Let's suppose I maintain a module for a react component, and am working on a PR to add a new feature.

As part of that feature work, let's also suppose I've refactored the component to remove some internals that were previously visible if you'd captured a Jest snapshot of the rendered component. (Suppose I've removed an internal intermediate component and not anything that affects the DOM output of the component). Functionally, the component is identical and all existing code is compatible.

Should I release my feature as a new major version of the component because some users' snapshot tests might need to be updated? Or is a minor version bump sufficient?


Solution

  • Answering my own question here.

    As RobC points out, it boils down to whether the public API has changed or broken. After some thought, I'm persuaded that a Jest snapshot of an Enzyme render that includes internals not visible in the final rendered DOM is more like leakage of a private API, and therefore not intended to be protected by a major semver bump.

    I published my change as a minor version. Will comment on this answer if users complain.