Issue #2954Opened August 12, 2020by ghost0 reactions

BUG: Cannot run preview mode when test with Jest

Question

Version: 0.15.10

Hi! I am using Jest for testing my Grapes.js components. I need test my components behavior in a different environment like an edit mode and preview mode in Grapes.js editor. When I test in edit mode everything is fine but when I need test in preview mode I try to run script editor.runCommand('preview') and I get error. The tests are working in node.js but I succeeded to debug it in Google developer panel, so we can touch the code from within.

image

If we get to the point where the error appears, we understand that this.getDoc() returns null:

image

When I start my Grapes.js project in usual mode I saw in debugger that this.getDoc() must return contentDocument of iframe element:

image

So someone have any ideas how to solve the problem with contentDocument is null in Jest?

Answers (1)

ghostAugust 17, 20200 reactions

I forget to add editor wrap element in current document so editor initializing by me was not existing in DOM

The solution on 12 line:

<img width="488" alt="solution" src="https://user-images.githubusercontent.com/48758473/90397413-77f2a000-e0a0-11ea-9f99-c8d43fef06c8.png">

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.