Does anybody face the mistake with Jest: “Could not locate module meteor/react-meteor-data” ?
How it can be fixed?
What should I use at jest.config.js?
Thanks!
Does anybody face the mistake with Jest: “Could not locate module meteor/react-meteor-data” ?
How it can be fixed?
What should I use at jest.config.js?
Thanks!
// jest.config.js
module.exports = {
moduleNameMapper: {
'^meteor/(.*)': '<rootDir>/mocks/meteor/$1'
}
}
This basically tells jest to look for imports starting with meteor/ in the mocks/meteor file (the default is node_modules).
So in your case it will look for a file named react-meteor-data
// mocks/meteor/react-meteor-data.js
import React, { Component } from 'react'
export const withTracker = (options) => {
let options_ = options
if (typeof options === 'function') {
options_ = options()
}
return (WrappedComponent) => (
class ReactMeteorData extends Component {
render () {
return <WrappedComponent {...options_} />
}
}
)
}
I assume that you don’t run jest in the context of meteor so you only need the withTracker function to pass props (by entering an object/function as parameter) to your component and return it.
Ask anything if it doesn’t make any sense to you