question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: config.transforms[index] is not a function

See original GitHub issue

Subject of the issue

Failing unit tests when using react-markdown which using this library

   ● Some test with react-markdown in jest using testing-library
     TypeError: config.transforms[index] is not a function
   
at compile (../node_modules/mdast-util-from-markdown/dist/index.js:226:38)
at fromMarkdown (../node_modules/mdast-util-from-markdown/dist/index.js:24:27)
at parse (../node_modules/remark-parse/index.js:13:12)
at Function.parse (../node_modules/unified/index.js:284:12)
at ReactMarkdown (../node_modules/react-markdown/lib/react-markdown.js:42:42)
at renderWithHooks (../node_modules/react-dom/cjs/react-dom.development.js:16260:18)
at mountIndeterminateComponent (../node_modules/react-dom/cjs/react-dom.development.js:18794:13)
at beginWork$1 (../node_modules/react-dom/cjs/react-dom.development.js:20162:16)
at HTMLUnknownElement.callCallback (../node_modules/react-dom/cjs/react-dom.development.js:336:14)
at invokeEventListeners (../node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
at HTMLUnknownElementImpl._dispatch (../node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
at HTMLUnknownElementImpl.dispatchEvent (../node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
at HTMLUnknownElementImpl.dispatchEvent (../node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
at HTMLUnknownElement.dispatchEvent (../node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
at Object.invokeGuardedCallbackDev (../node_modules/react-dom/cjs/react-dom.development.js:385:16)
at invokeGuardedCallback (../node_modules/react-dom/cjs/react-dom.development.js:440:31)
at beginWork$$1 (../node_modules/react-dom/cjs/react-dom.development.js:25780:7)
at performUnitOfWork (../node_modules/react-dom/cjs/react-dom.development.js:24698:12)
at workLoopSync (../node_modules/react-dom/cjs/react-dom.development.js:24671:22)
at performSyncWorkOnRoot (../node_modules/react-dom/cjs/react-dom.development.js:24270:11)
at ../node_modules/react-dom/cjs/react-dom.development.js:12199:24
at unstable_runWithPriority (../node_modules/scheduler/cjs/scheduler.development.js:697:12)
at runWithPriority$2 (../node_modules/react-dom/cjs/react-dom.development.js:12149:10)
at flushSyncCallbackQueueImpl (../node_modules/react-dom/cjs/react-dom.development.js:12194:7)
at flushSyncCallbackQueue (../node_modules/react-dom/cjs/react-dom.development.js:12182:3)
at scheduleUpdateOnFiber (../node_modules/react-dom/cjs/react-dom.development.js:23709:9)
at dispatchAction (../node_modules/react-dom/cjs/react-dom.development.js:17076:5)

Your environment

  • OS: Mac os
  • Packages: version “0.8.4”
  • Env: node 15, yarn 1.22, jest 26

Steps to reproduce

rendering a markdown with react-markdown. it works in our prod. works when working locally with the unit tests but it fails in our pipeline so I’m really sorry that i cant reproduce that easily. but maybe that’s enught for you to tackle or understand what’s the issue or if mdast-util-from-markdown should handle that case

Expected behavior

What should happen? handle that case, without exploding or provide a better error explaining what went wrong

Actual behavior

exploding on this code block image https://github.com/syntax-tree/mdast-util-from-markdown/blob/16c95f55298acb90f69cd253601672eb78e1b4d4/lib/index.js#L225

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlonMizcommented, Feb 3, 2021

Thanks, will try

1reaction
wooormcommented, Feb 3, 2021

Fixed already: rm -r node modules; npm install should do the trick!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"index.js: Transformer.transform is not a function" #29301
After upgrading react-native from 0.48.3 to 0.62.2 I get the error when running "react-native run-ios" command: "index.js: Transformer.transform ...
Read more >
React-native: index.js: Transformer.transform is not a function
... to 0.62.2 on a project I get the error when running "react-native run-ios" command: "index.js: Transformer.transform is not a function".
Read more >
TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >
TypeError: forEach is not a function in JavaScript
The "TypeError: forEach is not a function" error occurs when we call the forEach() method on a value that is not of type...
Read more >
Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... TypeError: createAsyncThunk is not a function TypeError: default is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found