Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Jest 28+ #7

Open
jameskraus opened this issue Oct 24, 2022 · 3 comments
Open

Fix for Jest 28+ #7

jameskraus opened this issue Oct 24, 2022 · 3 comments

Comments

@jameskraus
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Jest has changed the function signature for transformers from (args) => string to (args) => { 'code': string }:
https://jestjs.io/docs/28.x/upgrading-to-jest28#transformer

Here is the diff that solved my problem:

diff --git a/node_modules/svg-jest/index.js b/node_modules/svg-jest/index.js
index 20167b5..26adbb2 100644
--- a/node_modules/svg-jest/index.js
+++ b/node_modules/svg-jest/index.js
@@ -2,7 +2,7 @@ const path = require('path');
 
 function buildModule(functionName, pathname, filename)
 {
-	return `
+	return { code: `
 const React = require('react');
 
 const ${functionName} = (props) => 
@@ -17,7 +17,7 @@ const ${functionName} = (props) =>
 
 module.exports.default = ${functionName};
 module.exports.ReactComponent = ${functionName};
-`;
+`};
 }
 
 function createFunctionName(base)

This issue body was partially generated by patch-package.

@jameskraus
Copy link
Author

Here's a PR which fixes the problem:
#8

@jameskraus
Copy link
Author

Ah, seems like this is already fixed in #5

@Ronald-Cifuentes
Copy link

Ronald-Cifuentes commented Jul 23, 2023

@jameskraus this is fork with your suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants