RequireJs loading modules - Qunit

前端 未结 3 520
天命终不由人
天命终不由人 2020-12-11 08:28

I am pretty new to RequireJS, and having trouble in writing QUnit to a source code which has logic to load modules dynamically using requireJS.

Be

3条回答
  •  难免孤独
    2020-12-11 08:39

    First, a clarification: What does your QUnit test page look like? I'm guess it's either listing zero tests, or is a blank page.

    If that's the case, I had a lot of trouble with the same thing. The "right" answer is exactly what you are doing. But after a lot of stepping through code, in my setup, QUnit was still starting before any of my tests were defined, despite setting QUnit.config.autostart = false.

    At the end of testsuite.js, try calling QUnit.load() instead of QUnit.start() (you can probably drop the autostart = false, too). This is an undocumented function, but it was the only thing that worked for me. I believe it's the function QUnit attaches to the onLoad event by default. Unfortunately, with RequireJS, the onLoad triggers before most of your js files have loaded.

提交回复
热议问题