jest-styled-components
Advanced tools
Comparing version 7.0.7 to 7.0.8
@@ -8,2 +8,13 @@ # Changelog | ||
## [7.0.7](https://github.com/styled-components/jest-styled-components/compare/v7.0.7...v7.0.7) - 2021-11-21 | ||
- Fix issue #317 (#319) | ||
After the first render the node are marked with KEY property and calling rerender function of react-testing-library the test function will return false preventing the print to work as expected | ||
- fix: incorrect negated assertion for rule existence check | ||
- Fix native toHaveStyleRule to work with object style props (#337) | ||
- Make the global installation [instructions] clearer (#323) | ||
- minor dependency updates | ||
## [7.0.6](https://github.com/styled-components/jest-styled-components/compare/v7.0.5...v7.0.6) - 2021-11-09 | ||
@@ -10,0 +21,0 @@ |
{ | ||
"name": "jest-styled-components", | ||
"version": "7.0.7", | ||
"version": "7.0.8", | ||
"description": "Jest utilities for Styled Components", | ||
@@ -29,4 +29,2 @@ "main": "./src/index.js", | ||
"@babel/eslint-parser": "^7.16.3", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0", | ||
"@babel/preset-env": "^7.16.4", | ||
@@ -37,4 +35,4 @@ "@babel/preset-react": "^7.0.0", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^26.0.0", | ||
"babel-jest": "^27.3.1", | ||
"babel-plugin-styled-components": "^2.0.1", | ||
"enzyme": "^3.6.0", | ||
@@ -47,4 +45,4 @@ "enzyme-adapter-preact-pure": "^3.3.0", | ||
"husky-v4": "^4.3.8", | ||
"jest": "^26.0.0", | ||
"lint-staged": "^12.0.3", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^12.1.1", | ||
"preact": "^10.0.0-beta.2", | ||
@@ -86,2 +84,3 @@ "preact-render-to-json": "^3.6.6", | ||
], | ||
"testEnvironment": "jsdom", | ||
"testPathIgnorePatterns": [ | ||
@@ -88,0 +87,0 @@ "<rootDir>/test/native", |
const css = require('css'); | ||
const { getCSS, getHashes } = require('./utils'); | ||
let cache = new WeakSet() | ||
let cache = new WeakSet(); | ||
const getNodes = (node, nodes = []) => { | ||
@@ -43,5 +43,7 @@ if (typeof node === 'object') { | ||
const isStyledClass = (className) => /^\.?(\w+(-|_))?sc-/.test(className); | ||
const filterClassNames = (classNames, hashes) => classNames.filter((className) => hashes.includes(className)); | ||
const filterUnreferencedClassNames = (classNames, hashes) => | ||
classNames.filter((className) => className.startsWith('sc-') && !hashes.includes(className)); | ||
classNames.filter((className) => isStyledClass(className) && !hashes.includes(className)); | ||
@@ -54,3 +56,3 @@ const includesClassNames = (classNames, selectors) => | ||
.flatMap((selector) => selector.split(' ')) | ||
.filter((chunk) => chunk.includes('sc-')) | ||
.filter((chunk) => isStyledClass(chunk)) | ||
.every((chunk) => classNames.some((className) => chunk.includes(className))); | ||
@@ -115,3 +117,3 @@ | ||
addStyles: true, | ||
classNameFormatter: (index) => `c${index}` | ||
classNameFormatter: (index) => `c${index}`, | ||
}; | ||
@@ -121,3 +123,2 @@ let serializerOptions = serializerOptionDefaults; | ||
module.exports = { | ||
/** | ||
@@ -131,3 +132,3 @@ * Configure jest-styled-components/serializer | ||
...serializerOptionDefaults, | ||
...options | ||
...options, | ||
}; | ||
@@ -160,3 +161,3 @@ }, | ||
let result = serializerOptions.addStyles ? `${style}${style ? '\n\n' : ''}${code}`: code; | ||
let result = serializerOptions.addStyles ? `${style}${style ? '\n\n' : ''}${code}` : code; | ||
result = stripUnreferencedClassNames(result, unreferencedClassNames); | ||
@@ -163,0 +164,0 @@ result = replaceClassNames(result, classNamesToReplace, style, serializerOptions.classNameFormatter); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43073
27
364