TypeError: t.test is not a function
See original GitHub issueBefore you open an issue, please check if a similar issue already exists or has been closed before.
When reporting a bug, please try to include the following:
- A descriptive title
- An isolated way to reproduce the behavior (example: GitHub repository with code isolated to the issue that anyone can clone to observe the problem)
- What package and version you’re using, and the platform(s) you’re running it on
- The behavior you expect to see, and the actual behavior
https://github.com/dotnetCarpenter/bug-postcss-purgecss
Steps to reproduce:
git clone git@github.com:dotnetCarpenter/bug-postcss-purgecss.git && cd bug-postcss-purgecss
yarn install
yarn build
- Observe the errors in your terminal.
Enabling/disabling plugins in postcss.config.js seems to suggest the postcss-import
plugin being the culprit. Disabling postcss-import
does remove the errors but does not generate a valid CSS file. It probably only remove the errors because purgecss is not actually doing any work.
Actual behavior
Tens of similar error messages.
yarn run v1.22.5
$ postcss src/style.css --config postcss.config.js --output _site/assets/style.css
(node:10007) UnhandledPromiseRejectionWarning: TypeError: t.test is not a function
at /home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/lib/purgecss.js:1:7958
at Array.some (<anonymous>)
at U.isSelectorSafelistedDeep (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/lib/purgecss.js:1:7948)
at U.shouldKeepSelector (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/lib/purgecss.js:1:9213)
at /home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/lib/purgecss.js:1:6477
at /home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/node_modules/postcss-selector-parser/dist/selectors/container.js:228:20
at Root.each (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/node_modules/postcss-selector-parser/dist/selectors/container.js:210:16)
at Root.walk (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/node_modules/postcss-selector-parser/dist/selectors/container.js:227:17)
at Processor.func (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/lib/purgecss.js:1:6439)
at Processor._runSync (/home/dotnet/projects/playground/bug-postcss-purgecss/node_modules/purgecss/node_modules/postcss-selector-parser/dist/processor.js:104:26)
(node:10007) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10007) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The resulting CSS file look fine.
Expected behavior
The same as the actual behavior but without all of the errors.
- OS: Ubuntu 20.04 (WSL2 Windows 10)
- Nodejs: v12.18.3
- purgecss: 3.0.0
- @fullhuman/postcss-purgecss: 3.0.0
- PostCSS: 7.0.34
- PostCSS CLI: 7.1.2
- autoprefixer: 7.2.6
- postcss-css-variables: 0.17.0
- postcss-import: 12.0.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
TypeError: pattern.test is not a function - Stack Overflow
it gives me an error: "TypeError: pattern.test is not a function" ("pattern" referring to the first function's (filterPhone) variable name ...
Read more >TypeError: t.test is not a function - support - HUGO
1. Made sure the extended version is installed, and tried installing the packages mentioned in the error message: purgecss and cssnano. I'm at...
Read more >TypeError: regex test is not a function in JavaScript | bobbyhadz
The "test is not a function" error occurs when the test() method is called on a value that is not a regular expression,...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >JavaScript `.test()` is not a function - The freeCodeCamp Forum
method is applied on the regular expression and the string to be matched is provided as an argument.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it’s because
deep
andgreedy
should be an array of RegExp instead of string.yes, it would make it easier to return useful error messages. Thanks a lot for the link to the article! I was looking into rust recently so that’s perfect.