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

Issue with Jest v28 #33842

Closed
billnbell opened this issue May 17, 2022 · 7 comments
Closed

Issue with Jest v28 #33842

billnbell opened this issue May 17, 2022 · 7 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@billnbell
Copy link
Contributor

Jest needs { code: } process() fix per upgrade guide.

+  process: (_, filename) => {
+    return {
+      code: `module.exports = {
+        testUri:
+          ${JSON.stringify(
+            path.relative(__dirname, filename).replace(/\\/g, '/'),
+          )}
+      };`,
+    }
+  },

@cipolleschi cipolleschi added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label May 17, 2022
@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@cortinico cortinico added the Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. label May 19, 2022
@github-actions
Copy link

⚠️ Missing Required Fields
ℹ️ It looks like your issue may be missing some necessary information. GitHub provides an example template whenever a new issue is created. Could you go back and make sure to fill out the template? You may edit this issue, or close it and open a new one.

@billnbell
Copy link
Contributor Author

No I cannot. It is super simple. Please upgrade Jest to "^28.1.0" and see this link for upgrading from 27 to 28.

https://jestjs.io/docs/upgrading-to-jest28

You have to add code: ... see

Transformer[​](https://jestjs.io/docs/upgrading-to-jest28#transformer)

process() and processAsync() methods of a custom [transformer module](https://jestjs.io/docs/code-transformation) cannot return a string anymore. They must always return an object:

  process(sourceText, sourcePath, options) {
-   return `module.exports = ${JSON.stringify(path.basename(sourcePath))};`;
+   return {
+     code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`,
+   };
  }

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels May 19, 2022
@billnbell
Copy link
Contributor Author

The full patch is: react-native+0.68.2.patch

diff --git a/node_modules/react-native/jest/assetFileTransformer.js b/node_modules/react-native/jest/assetFileTransformer.js
index b735796..43b8203 100644
--- a/node_modules/react-native/jest/assetFileTransformer.js
+++ b/node_modules/react-native/jest/assetFileTransformer.js
@@ -20,12 +20,15 @@ module.exports = {
   // the correct images are loaded for components. Essentially
   // require('img1.png') becomes `Object { "testUri": 'path/to/img1.png' }` in
   // the Jest snapshot.
-  process: (_, filename) =>
-    `module.exports = {
-      testUri:
-        ${JSON.stringify(
-          path.relative(__dirname, filename).replace(/\\/g, '/'),
-        )}
-    };`,
+  process: (_, filename) => {
+    return {
+      code: `module.exports = {
+        testUri:
+          ${JSON.stringify(
+            path.relative(__dirname, filename).replace(/\\/g, '/'),
+          )}
+      };`,
+    }
+  },
   getCacheKey: createCacheKeyFunction([__filename]),
 };

@ginnymin
Copy link

ginnymin commented Jun 4, 2022

I think this PR addresses this issue? Just waiting for it to get merged...
#33756

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 2, 2022
@github-actions
Copy link

github-actions bot commented Dec 9, 2022

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as completed Dec 9, 2022
@facebook facebook locked as resolved and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

4 participants