1.3.1 • Published 5 years ago

jest-three v1.3.1

Weekly downloads
53
License
MIT
Repository
github
Last release
5 years ago

jest-three

Jest testing utilities for Three.js. Includes a snapshot serializer for Three.js objects.

Installation

npm install --save-dev jest-three

Snapshot Serializer

The easiest way to test Three.js objects is with the snapshot serializer. You can register the serializer via the snapshotSerializers configuration property in your jest configuration like so:

// jest.config.js
module.exports = {
  snapshotSerializers: ["jest-three"]
};

Or you can customize the serializer via the createSerializer method like so:

import { createSerializer } from "jest-three";

expect.addSnapshotSerializer(
  createSerializer({
    shouldReplaceUUIDs: true
  })
);

You can also import toJSON to use the snapshot serializer in one assertion, like so:

import { toJSON } from "jest-three";

expect(toJSON(object)).toMatchSnapshot();
// …where `object` is an instance of `THREE.Object3D`

Thanks

Thanks to Dan Kaplun who wrote three-snapshot-serializer which this library is based on.

1.3.1

5 years ago

1.3.0

5 years ago