You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When transit-js gets imported into jest I get the following error:
TypeError: Cannot read property 'Buffer' of undefined
1 | import React from "react"
> 2 | import { Builder, Query, Utils } from "react-awesome-query-builder"
| ^
3 |
4 | import configFn from "./config"
5 | import "./styles.less"
at Object.defaultHandlers (node_modules/transit-js/transit.js:3222:37)
at new Object.<anonymous>.com.cognitect.transit.handlers.Handlers (node_modules/transit-js/transit.js:3228:34)
at new Object.<anonymous>.com.cognitect.transit.impl.writer.JSONMarshaller (node_modules/transit-js/transit.js:3482:19)
at Object.writer (node_modules/transit-js/transit.js:3770:13)
at createWriter (node_modules/transit-immutable-js/index.js:63:18)
at createInstanceFromHandlers (node_modules/transit-immutable-js/index.js:240:16)
at Object.<anonymous> (node_modules/transit-immutable-js/index.js:303:18)
at Object.<anonymous> (node_modules/react-awesome-query-builder/lib/import/tree.js:22:15)
at Object.<anonymous> (node_modules/react-awesome-query-builder/lib/import/index.js:7:13)
at Object.<anonymous> (node_modules/react-awesome-query-builder/lib/index.js:36:38)
at Object.<anonymous> (packages/shared-query-builder/src/DemoQueryBuilder.tsx:2:1)
at Object.<anonymous> (packages/shared-query-builder/src/index.js:1:1)
at Object.<anonymous> (src/domains/scorecards/LayerForm/LayerForm.jsx:2:1)
at Object.<anonymous> (src/domains/scorecards/LayerForm/__tests__/LayerForm.spec.jsx:4:1)
Seems that goog.global isn't an object, and there was no working way for me to modify window/globals to get this to have some inject value (no window.Buffer or window.goog = window.goog || {} or globals.Buffer etc).
I tried a whole bunch of jest config settings and require vs import and all had similar issues.
The only thing I did note was that the "react-awesome-query-builder" from which this is a dependency includes node: {Buffer: false} in their webpack config. I tried setting this as well but to no avail.
The only other thing of note was that all other modules were imported but "transit-immutable-js" was required?
When
transit-js
gets imported intojest
I get the following error:The specific function failing is:
specifically the clause:
Seems that
goog.global
isn't an object, and there was no working way for me to modify window/globals to get this to have some inject value (nowindow.Buffer
orwindow.goog = window.goog || {}
orglobals.Buffer
etc).I tried a whole bunch of jest config settings and require vs import and all had similar issues.
The only thing I did note was that the "react-awesome-query-builder" from which this is a dependency includes
node: {Buffer: false}
in their webpack config. I tried setting this as well but to no avail.The only other thing of note was that all other modules were imported but "transit-immutable-js" was required?
Thoughts?
Reference issue: ukrbublik/react-awesome-query-builder#254
The text was updated successfully, but these errors were encountered: