Currently the styles are added to the snapshot string as if writing to a CSS file. However the snapshot file really represents a HTML and so the styles should reside inside a <style> element.
This means a snapshot file can be viewed in a browser as something like:

instead of text with the raw CSS prepended.
This can be simply done by replacing the line:
let result = `${style}${style ? '\n\n' : ''}${code}`
in the file styleSheetSerializer.js with this line:
let result = `${style ? '<style>\n' : ''}${style}${style ? '\n</style>\n\n' : ''}`
Even better, if the snapshotSerializer jest-html is ordered after jest-styled-components then the styled-components CSS will be included in its preview. (Unfortunately I can't get the jest-html serializer to happen after the jest-styled-component serializer. Any ideas?)
Currently the styles are added to the snapshot string as if writing to a CSS file. However the snapshot file really represents a HTML and so the styles should reside inside a
<style>element.This means a snapshot file can be viewed in a browser as something like:

instead of text with the raw CSS prepended.
This can be simply done by replacing the line:
in the file
styleSheetSerializer.jswith this line:Even better, if the snapshotSerializer
jest-htmlis ordered afterjest-styled-componentsthen the styled-components CSS will be included in its preview. (Unfortunately I can't get thejest-htmlserializer to happen after thejest-styled-componentserializer. Any ideas?)