Skip to content

Releases: preactjs/enzyme-adapter-preact-pure

v4.1.0

05 Jan 19:57
Compare
Choose a tag to compare

Summary

Add new features behind flags to increase compatibility with React Enzyme adapters

What's Changed

  • Adds a new shallow renderer that more closely matches the behavior of the React 16 shallow renderer. This new renderer can be enabled by importing CompatShallowRenderer from enzyme-adapter-preact-pure/compat and passing it in the ShallowRenderer Adapter option.

    The previous shallow renderer rendered components into a DOM and modified the component's output so that all children return null to prevent rendering further down the tree. The compat shallow renderer is a custom implementation of Preact's diffing algorithm that only shallow renders the given component and does not recurse down the VDOM tree. It's behavior more closely matches the React 16 Enzyme adapter and it well suited for migrating an Enzyme test suite from React to Preact.

  • Support more return types (e.g. booleans, numbers, BigInts) from components

  • Add an option (renderToString) to allow passing in a custom string renderer to use for Enzyme's 'string' renderer instead of rendering into the DOM and reading the HTML output. It is expected that renderToString from preact-render-to-string is passed into this option. This change enables using the string renderer in non-DOM environments and more closely matches the React adapter's behavior.

  • Add a feature flag (simulateEventsOnComponents) for supporting simulating events on Components #211

    This new feature flag turns on behavior that enables calling .simulate directly on Components. For shallow rendering, this directly calls the component's corresponding prop. For mount rendering, it finds the first DOM node in the Component, and dispatches the event from it.

    NOTE: This flag changes the behavior of calling simulate on shallow rendered host (a.k.a DOM) nodes. When this flag is off, simulate dispatches a native DOM event on the host node. When this flag is turned on, simulate directly calls the prop of the event handler with arguments passed to simulate.

    The behavior turned on by this flag matches the behavior of the React 16 Enzyme adapter.

Pull Requests

(bump dependency PRs not included)

New Contributors

Full Changelog: v4.0.1...v4.1.0

v4.0.1

15 Apr 11:25
Compare
Choose a tag to compare
  • Added a partial fix for an incompatibility between Preact's JSX element type
    and the JSX element type from @types/react v18.
    #177.

v4.0.0

13 Apr 10:54
Compare
Choose a tag to compare

Breaking changes

  • The CommonJS build of this package now targets ES 2020, which is the same
    target as the ESM build #166.

    If running tests against a pre-2020 browser or version of Node, you may need
    to add a polyfill for Array.prototype.flatMap in your own project.

v3.4.0

24 Feb 07:52
Compare
Choose a tag to compare
  • Support wrappingComponent and wrappingComponentProps options for full
    (mount) and shallow rendering. Thanks @kevinweber. #157

v3.3.0

09 Nov 12:07
Compare
Choose a tag to compare
  • simulateEvent now initializes the bubbles, cancelable and composed
    properties of dispatched events as they would be in real events. #131.

v3.2.0...v3.3.0

v3.2.0

03 Nov 15:01
Compare
Choose a tag to compare
  • Add an ES module build of the package for modern browsers and bundlers.
    #151

Support `invoke` wrapper method

08 Apr 16:27
Compare
Choose a tag to compare
  • Add support for invoke wrapper method. The Preact adapter currently only supports this for full (mount) rendering #135

v3.0.0...v3.1.0

Remove support for Preact v8

11 Jan 12:20
Compare
Choose a tag to compare

This release removes support for Preact v8 to simplify ongoing maintenance. See #117.

Users of Preact v8 will need to either stick with the last 2.x release of this package or upgrade their applications to Preact v10.

Fix `simulate` error in JSDOM

09 Jan 08:33
Compare
Choose a tag to compare

nb. This was intended to have been a patch rather than minor release.

  • Fix error when setting certain event properties when calling simulate() in an environment that uses JSDOM #125

v2.2.3...v2.3.0

Another small fix for shallow rendering

11 Aug 12:49
Compare
Choose a tag to compare
  • Fix a regression in 2.2.1 when a component that is stubbed out during shallow
    rendering is passed a number as a child #120

v2.2.2...v2.2.3