Provide a utils to mock the Editor instance in Jest
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m trying to test my app with Jest that depends on TinyMCE editor.
The problem is that when I run my tests with React Testing Library, the editor init_instance_callback
is not called, and I need it to be called to alocate the editor instance inside the useState(). Maybe the Iframe has some delay?
Describe the solution you’d like Provide a mock to mock the editor in Jest or a good example on how to do it.
Describe alternatives you’ve considered
Is there a way to mock the Editor in Jest and make the init_instance_callback
be called? Is there a clear example in some repository?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to mock the instance function of another class using Jest
You could use jest.mock(moduleName, factory, options) to mock ./MyAnotherClass module and B class. E.g.. MyClass.ts : import { B } from '.
Read more >The only 3 steps you need to mock an API call in Jest
1. Import the module you want to mock into your test file. 2. jest.mock() the module. 3. Use .
Read more >ES6 Class Mocks - Jest
The module factory function passed to jest.mock(path, moduleFactory) can be a HOF that returns a function*. This will allow calling new on the ......
Read more >Module Mocking in Jest - codeburst
In this article, we'll walk through various scenarios using ES6 modules with named exports, a default export, or a mix of both. ES6...
Read more >React app testing: Jest and React Testing Library
Here, the test case is provided by Jest. For rendering and accessing the virtual DOM, we import and use both render and screen...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Disable theme loading by setting
theme: false
, essentially running tiny in headless mode. I tried that with your example repo and it worked better(I suppose) but it failed on the same thing as in #61I’ll close this as jsdom isn’t anything that we’re planning on supporting (neither with a mock)
Did you get past #61 ?
Perhaps related to this.Try disabling skin css loading by setting
skin: false
in your init option. Like I mentioned in the other issue though jsdom isn’t officially supported by TinyMCE so there could be any number if issues that prevents it from working now.