You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/23 20:05:58 UTC

[GitHub] [arrow] tielushko commented on issue #11662: [JS] ReferenceError: TextDecoder is not defined - running tests with React Testing Library.

tielushko commented on issue #11662:
URL: https://github.com/apache/arrow/issues/11662#issuecomment-1049166247


   The top answer here: 
   
   https://stackoverflow.com/questions/57712235/referenceerror-textencoder-is-not-defined-when-running-react-scripts-test/57713960#57713960 
   
   seemed to resolve my issues. I also added the TextDecoder from utils and ran the test with the environment specified. 
   
   const Environment = require("jest-environment-jsdom");
   
   ```
   /**
    * A custom environment to set the TextEncoder and TextDecoder
    */
   module.exports = class CustomTestEnvironment extends Environment {
     async setup() {
       await super.setup();
       if (typeof this.global.TextEncoder === "undefined") {
         const { TextEncoder } = require("util");
         this.global.TextEncoder = TextEncoder;
       }
   
       if (typeof this.global.TextDecoder === "undefined") {
         const { TextDecoder } = require("util");
         this.global.TextDecoder = TextDecoder;
       }
     }
   };
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org