describe blocks not executed when inside SystemJS register block (which is executed)

112 views
Skip to first unread message

Francesco Belladonna

unread,
Aug 18, 2015, 1:38:11 PM8/18/15
to Jasmine
I'm facing an issue with Jasmine. I'm enclosing my tests in System.register (babel does this if you want to use ES6 modules). This is fine, I execute the registered block with System.import later on. However, tests inside it are not executed, although console.log calls are called:

System.register(["mymodule"], function (_export) {
 
"use strict";

 
var Mymodule;
 
return {
    setters
: [function (_mymodule) {
     
Mymodule = _mymodule["default"];
   
}],
    execute
: function () {

      console
.log("I'm here!!!");
      console
.log(Mymodule);

      describe
("Mymodule", function () {

        it
("has version", function () {
          expect
(Mymodule.VERSION).toEqual("1.0.0");
       
});


     
});
   
}
 
};
});

Both console.log calls are called and Mymodule is correctly initialized. However, the test is never run.
Are there any chance I can force Jasmine to detect this test?

Gregg Van Hove

unread,
Sep 3, 2015, 4:37:21 PM9/3/15
to jasmi...@googlegroups.com
I'm not really sure how SystemJS works, but I would guess that your callback from `register` is not called until after `window.onload` is triggered, or possibly as part of that event being triggered. Unfortunately, jasmine starts running any tests that have already been setup during the `window.onload` event as well, so if the SystemJS callbacks don't happen until after jasmine's, your specs won't be included in the suite execution.

Hope this helps,

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages