title.replaceAll is not a function
See original GitHub issue- @testing-library/react@9.5.0
- Jest
- Chrome 86
Relevant code or config:
const urlTitle: string = title.replaceAll(' ', '-');
What you did:
Testing a product list page
What happened:
TypeError: title.replaceAll is not a function
Problem description:
replaceAll function not being recognised, but replace function is fine
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Solved: "replaceAll is not a function" JavaScript TypeError
If you're seeing the error " TypeError: replaceAll is not a function ", it is likely due to the method not implemented/supported by...
Read more >Javascript .replaceAll() is not a function type error
When I run this, I receive Uncaught TypeError: string. replaceAll is not a function . Maybe I'm misunderstanding what a prototype is, but...
Read more >TypeError: replaceAll is not a function in JavaScript | bobbyhadz
The "replaceAll" is not a function error occurs when we call the replaceAll() method on a value that is not of type string,...
Read more >[Solved] TypeError: replaceAll is not a function - ItsJavaScript
The TypeError: replaceAll is not a function occurs if we call a replaceAll() method on the value that is not of a type...
Read more >Fix replaceAll is not a function in Node JS - Techozu
Easily fix the “replaceAll” is not a function error in NodeJS with the following solutions. ... The replace function is one of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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

You can just use https://github.com/es-shims/String.prototype.replaceAll
npm i string.prototype.replaceall -DMake sure you have the
setupFilesAfterEnvproperty in your Jest config. I use package.json so there I have:jestSetup.ts
The quickest fix is to use replace with regex.