massive-oss / MassiveUnit

munit is a cross-platform unit testing framework for Haxe. Utilises metadata markup for test cases and includes tools for generating, compiling and running test cases from the command line.
Other
181 stars 56 forks source link

Timer: fix undefined massive.munit.util error in JS #173

Closed joshtynjala closed 5 years ago

joshtynjala commented 5 years ago

The following code in the constructor for massive.munit.util.Timer causes runtime errors in JS:

id = arr.length;
arr[id] = this;
timerId = untyped window.setInterval("massive.munit.util.Timer.arr[" + id + "].run();", time_ms);

Error in Firefox:

TypeError: massive.munit.util is undefined

Error in Chrome:

TypeError: Cannot read property 'Timer' of undefined

This error makes it impossible for me to write async tests.

I should note that my project uses Haxe 4 and OpenFL, so I need to use the haxelib run openfl build html5 command to properly compile my tests.

My .hxml looks like this:

-lib openfl
-lib actuate
-lib munit
-cp ../src
-cp src

--each

--next

-cmd haxelib run openfl build html5
-js build/html5/bin/TestMain.js
joshtynjala commented 5 years ago

Closing. My mistake. I had accidentally started up two separate instances in my custom HTML runner template, and this seems to have caused a conflict.