I am trying to use mocha to create testcases for wix but for some reason my tests cases aren’t running even though ive connected it in my html element.
Here’s my code
I am trying to use mocha to create testcases for wix but for some reason my tests cases aren’t running even though ive connected it in my html element.
Here’s my code
Corvid understands all of Javascript, but not HTML, and not anything that accesses the DOM. This keeps the user from inadvertently “breaking” something. Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w.
See Corvid: JavaScript Support for details on Corvid’s Javascript support.
I don’t know what you mean by " connected it in my html element", however files in a Wix site cannot be accessed by code in an HtmlComponent. See Corvid: Working with the HTML Element for details on how to use an HtmlComponent.
Is there a way then, to send node_modules from the js files to the html component? I have to develop test cases for my website
You might consider using an NPM library installed via the Corvid Package Manager :
@kevinmarcelino17 The code that you have posted is not valid in a Corvid file and will not work. Try the NPM library.
@yisrael-wix Im sorry, im not sure what you mean by that? I have already installed the modules using the npm library
@kevinmarcelino17 And how are you calling the library? What code are you using?
@yisrael-wix I am using this
import chai from ‘./node_modules/chai';
import mocha from './node_modules/mocha';
@kevinmarcelino17 Where do you have that? What file? What code are you using? The code you posted before won’t work since Corvid doesn’t recognize HTML or code that accesses the DOM.
@yisrael-wix I have that in my html component of the website. Is there any way for the nodejs modules to be sent to the html components from the javascript files so that I could use the node js modules within the html component?
@kevinmarcelino17 No, the HtmlComponent is sandboxed. The only way that it can “talk” to the page is by messaging as explained in the article Corvid: Working with the HTML Element .