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.

Provide a utils to mock the Editor instance in Jest

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
SimonFccommented, Oct 4, 2019

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 #61

I’ll close this as jsdom isn’t anything that we’re planning on supporting (neither with a mock)

0reactions
SimonFccommented, Oct 4, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

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