MUnit and Jeash

47 views
Skip to first unread message

Alec McEachran

unread,
Dec 28, 2012, 12:48:11 AM12/28/12
to haxe...@googlegroups.com
Hi,

Using MUnit I'm running across a problem that when I attempt to use display-list elements, the JavaScript tests fail with the error:

Lib.hx|199| Error: Cannot find element ID 'haxe:jeash'

Before I start diving into MUnit to try to enclose the JS target test-runner is wrapped inside a haxe:jeash div, does anyone already know how to do this, or whether there's a worthwhile workaround? I've pinged Mike (the MUnit author) on Twitter too, but I think he's on holiday.

Thanks in advance!

Jason O'Neil

unread,
Dec 28, 2012, 2:18:31 AM12/28/12
to haxe...@googlegroups.com

Have a look at the munit wiki, there is some metadata you can use to run a function before the test class.

In this function, have a line (maybe some jquery) that creates the appropriate div and appends it to the body, if it doesn't exist already.

Hope that makes sense, let me know if you need more specific instructions.

Jason O'Neil

unread,
Dec 28, 2012, 2:40:37 AM12/28/12
to haxe...@googlegroups.com
Found the info, so you would do something like this:

import js.JQuery;

@BeforeClass public function beforeClass():Void { // This will run once per test class
var div =
new JQuery("#haxe:jeash");

if (div.length == 0)
{
div = new JQuery("<div id='haxe:jeash'></div>");
div.appendTo(js.Lib.document.body);
}

}
I haven't tested this code, but hopefully something like this would work...

Jason

misprintt

unread,
Dec 28, 2012, 6:09:44 PM12/28/12
to haxe...@googlegroups.com
Thanks again Jason, that's the easiest way, and can be used to reset after each test or test class

There are two other options. 

1. Create the jeash element in the generated TestMain.main before executing the test suite.

2. Set a custom HTML template by running 'munit config' and setting the path to a local template (and/or resources) directory.  See examples/02_customTemplates on github repo for example usage. This is a good option when tests depend on third party libraries and resources. 

Cheers,
Dom
Reply all
Reply to author
Forward
0 new messages