1.0.21 • Published 3 years ago
jest-serializer-react-helmet-async v1.0.21
jest-serializer-react-helmet-async
Jest Snapshot serializer to visualize react-helmet-async data alongside component snapshots.
Installation
Install preset using npm:
npm install --save-dev jest-serializer-react-helmet-async
or yarn:
yarn add --dev jest-serializer-react-helmet-async
Usage
Configure Jest to use the serializer in jest.config.js
:
module.exports = {
snapshotSerializers: ["jest-serializer-react-helmet-async"],
};
or package.json
:
{
"jest": {
"snapshotSerializers": ["jest-serializer-react-helmet-async"]
}
}
In your tests
Unlike jest-serializer-react-helmet
, this serializer does not automatically prepend the serialized data to the snapshots of your React components. You must add an assert for react-helmet-async
to be serialized.
Your test should like similar to the following:
import * as React from "react";
import renderer from "react-test-renderer";
import { HelmetProvider } from "react-helmet-async";
describe("App", () => {
it("renders as expected", () => {
const context = {};
const tree = renderer
.create(
<HelmetProvider context={context}>
<App />
</HelmetProvider>
)
.toJSON();
expect(tree).toMatchSnapshot();
expect(context.helmet).toMatchSnapshot();
});
});
Related Packages
jest-runner-prettier
- Use Jest to check your codebase againstprettier
jest-preset-gatsby
- Jest preset to ease unit testing a Gatsby projectjest-serializer-json-ld-script
- Jest snapshot serializer to better visualize React<script>
elements containing LD+JSON datajest-raw-loader
- Load the raw content of files in Jest, replicating the behavior ofwebpack
'sraw-loader
License
Copyright 2019 Kepler Sticka-Jones. Licensed ISC
1.0.21
3 years ago
1.0.20
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.16
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago