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
Getting TypeError: Cannot read property 'prefix' of undefined, test only #321
Comments
Solved it like this - // create a file called class RtcChannel { const View = require('react-native/Libraries/Components/View/View'); const RtcLocalView = View export default RtcEngine; // in jest.setup.js // in package json jest block - |
But you can still make this module testable. |
the test is just for mocking, it will be a low priority. |
@harshaliitr I'm getting the warning UPDATE: I think I figured it out. I ended up going with a different solution. Instead of creating a new file that mocks // jest.setup.js
jest.mock('react-native-agora', () => {
return {
__esModule: true,
default: {
create: jest.fn(() => ({
addListener: jest.fn(),
destroy: jest.fn(),
enableVideo: jest.fn(),
removeListener: jest.fn(),
// Add any additional methods on RtcEngine that you use
})),
},
};
}); And if you don't already have a module.exports = {
preset: 'react-native',
setupFiles: ['<rootDir>/jest.setup.js'],
// ...Whatever else you have in your config...
}; |
Facing the same issue, the above solution is not working for me. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am setting up jest in my project and get this error:
TypeError: Cannot read property 'prefix' of undefined at Object.<anonymous> (node_modules/react-native-agora/lib/src/RtcChannel.native.js:10:38) at Object.<anonymous> (node_modules/react-native-agora/lib/src/RtcEngine.native.js:3:1)
Do you have a mock available?
The text was updated successfully, but these errors were encountered: