1.3.1 • Published 6 years ago
jest-three v1.3.1
jest-three
Jest testing utilities for Three.js. Includes a snapshot serializer for Three.js objects.
Installation
npm install --save-dev jest-threeSnapshot 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.