{"name":"jest-emotion","version":"10.0.0-beta.6","description":"Jest utilities for emotion","main":"dist/index.cjs.js","types":"types/index.d.ts","scripts":{"test:typescript":"dtslint types"},"dependencies":{"@types/jest":"^23.0.2","chalk":"^2.4.1","css":"^2.2.1"},"devDependencies":{"dtslint":"^0.3.0","emotion":"^10.0.0-beta.6","preact":"^8.2.9","preact-render-to-json":"^3.6.6","pretty-format":"^22.4.3","react-emotion":"^10.0.0-beta.6"},"author":{"name":"Kye Hohenberger"},"homepage":"https://emotion.sh","license":"MIT","repository":{"type":"git","url":"https://github.com/emotion-js/emotion/tree/master/packages/jest-emotion"},"keywords":["styles","emotion","react","css","css-in-js","jest","snapshot"],"bugs":{"url":"https://github.com/emotion-js/emotion/issues"},"publishConfig":{"tag":"next"},"browser":{"./dist/index.cjs.js":"./dist/index.browser.cjs.js"},"readme":"# jest-emotion\n\n> Jest testing utilities for emotion\n\n# Installation\n\n```bash\nnpm install --save-dev jest-emotion\n```\n\n# Snapshot Serializer\n\nThe easiest way to test React components with emotion is with the snapshot serializer. You can register the serializer via the `snapshotSerializers` configuration property in your jest configuration like so:\n\n```js\n// jest.config.js\nmodule.exports = {\n  // ... other config\n  snapshotSerializers: ['jest-emotion']\n}\n```\n\nOr you can customize the serializer via the `createSerializer` method like so: (the example below is with react-test-renderer but jest-emotion also works with enzyme and react-testing-library)\n\n```jsx\nimport React from 'react'\nimport renderer from 'react-test-renderer'\nimport serializer from 'jest-emotion'\nimport styled from '@emotion/styled'\n\nexpect.addSnapshotSerializer(serializer)\n\ntest('renders with correct styles', () => {\n  const H1 = styled.h1`\n    float: left;\n  `\n\n  const tree = renderer.create(<H1>hello world</H1>).toJSON()\n\n  expect(tree).toMatchSnapshot()\n})\n```\n\nRefer to the [testing doc](https://github.com/emotion-js/emotion/blob/master/docs/testing.md) for more information about snapshot testing with emotion.\n\n## Options\n\n### `classNameReplacer`\n\njest-emotion's snapshot serializer replaces the hashes in class names with an index so that things like whitespace changes won't break snapshots. It optionally accepts a custom class name replacer, it defaults to the below.\n\n```jsx\nfunction classNameReplacer(className, index) {\n  return `emotion-${index}`\n}\n```\n\n```jsx\nimport { createSerializer } from 'jest-emotion'\n\nexpect.addSnapshotSerializer(\n  createSerializer({\n    classNameReplacer(className, index) {\n      return `my-new-class-name-${index}`\n    }\n  })\n)\n```\n\n### `DOMElements`\n\njest-emotion's snapshot serializer inserts styles and replaces class names in both React and DOM elements. If you would like to disable this behavior for DOM elements, you can do so by passing `{ DOMElements: false }`. For example:\n\n```jsx\nimport { createSerializer } from 'jest-emotion'\n\n// configures jest-emotion to ignore DOM elements\nexpect.addSnapshotSerializer(createSerializer({ DOMElements: false }))\n```\n\n# Custom matchers\n\n## toHaveStyleRule\n\nTo make more explicit assertions when testing your styled components you can use the `toHaveStyleRule` matcher.\n\n```jsx\nimport React from 'react'\nimport renderer from 'react-test-renderer'\nimport { matchers } from 'jest-emotion'\nimport styled from 'react-emotion'\n\n// Add the custom matchers provided by 'jest-emotion'\nexpect.extend(matchers)\n\ntest('renders with correct styles', () => {\n  const H1 = styled.h1`\n    float: left;\n  `\n\n  const tree = renderer.create(<H1>hello world</H1>).toJSON()\n\n  expect(tree).toHaveStyleRule('float', 'left')\n  expect(tree).not.toHaveStyleRule('color', 'hotpink')\n})\n```\n\n## Thanks\n\nThanks to [Kent C. Dodds](https://twitter.com/kentcdodds) who wrote [jest-glamor-react](https://github.com/kentcdodds/jest-glamor-react) which this library is largely based on. ❤️\n","readmeFilename":"README.md","_id":"jest-emotion@10.0.0-beta.6","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"mitchellhamilton","email":"mitchell@mitchellhamilton.me"},"dist":{"integrity":"sha512-ddNb2NYyw9GTQZVllOUCVWvEKWkrO3XZGPTIrZTghrE6cCuQSAeXUQzJVY81WdeJXtqSBy2g6v9rtfBOMRPJTg==","shasum":"6666c362a7cf944fe79bf2dc8576b9b39709f55a","tarball":"http://registry-npm.ywwl.com/jest-emotion/download/jest-emotion-10.0.0-beta.6.tgz","fileCount":16,"unpackedSize":43609,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb0/XdCRA9TVsSAnZWagAA5V8P/jRy3DIrI592QICtp+Dw\nDWvY2GS3WwOkewkNSp9vBXK9bdL0v1qOCORp4P6hcn9cYLwxKE3iXcgKoNR5\n67J+CznUdoFPNOCqmpitwlbR+dXvmqtY/YzRBCHPPDa3HFlGzHFkuXPmc9Ug\ncydNaL9CKepuTYa/ZpR/BSFwndU45Lb7Z1284jlto9fnrARAqfsKgAcETdzG\neQaKI0A+rBJZH1ad4phe9SS+n6detkGyEI/cG1VCojIWcZ0Be1foXRthtD9d\nKBtmtEPz8PFWaABWQjio/mn56ghQc76xaZVZbKuBtTE/qzTZqsJ/ULRQ3FN9\nZ6Dy5ifF8gpTp2mSATip2phPVunEr0ixOBuZpEraH5edF/7I7bt0eLTl3rAl\nZ6FoY1zNtI2sala7eVLhybgv+dOy/gjZ5bdmv1l3YQxkXJCshbdWh0XwvU0Z\n1j+d5DknOhmRLBHouZvEeTjo7+wPRUFVmt51JZAUvuR24zdhyQdLe3xsz9W6\nsNaBSxPFGDcI+1LR/S/Cp5GltEo+31KIHwCslhtqvrsapmKBf6tCjXH0hwhS\nkGhkfaPd9cIFUsnbg4H5UWs1p+FPylR9TJBrjJsMP+m3zzXFrU1Pi5ws372j\nYUGokz/2d41Hq9wz2ZpdcaIOuDfiDG3MPfTTgUbrTzjH91cjqBLyBQkTsy/Q\nYvAu\r\n=/ZA9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGGPtT/Dbhxh4ra+w8sU5CGPtkZW5EuelQsp5KwOykgQIhAKbngvCqKubzdsqKGQC1Xk364pz116nKlBReDc94bICp"}],"size":8453,"noattachment":false,"key":"/jest-emotion/-/jest-emotion-10.0.0-beta.6.tgz"},"maintainers":[{"email":"mitchell@mitchellhamilton.me","name":"mitchellhamilton"},{"email":"kye.hohenberger@gmail.com","name":"tkh44"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jest-emotion_10.0.0-beta.6_1540617692521_0.04921396601329309"},"_hasShrinkwrap":false,"publish_time":1540617692677,"_cnpm_publish_time":1540617692677,"dist-tags":{"latest":"11.0.0","next":"11.0.0-next.10","rc":"11.0.0-rc.0"}}