Intern JS Testing not Publishing JUnit XML File?

Just another random issue I couldn’t find the answer to by googling and finally figured out.

Issue: You have used the Yeoman Dojo generator to init a dojo boilerplate project.

This generator includes the files necessary for using intern to do JS unit testing in your dojo AMD javascript.

You would like to integrate your results into a CI build, and need xml results in order to do that.

You follow the Intern user guide and put the following in the intern config file:

reporters: [
{ id: ‘JUnit’, filename: ‘report.xml’ }
]

You run grunt intern.

You get no report.xml.

You are sad and confused.

😦

Solution:

I suppose that Intern was updated after the yeoman generator was put together. If you look in “node_modules” you’ll see that it includes “intern-geezer”. Not “intern”. I do not know why this is. However, now you know what to do, uninstall “intern-geezer” and install “intern”.

in terminal, within the project folder :
“npm uninstall intern-geezer –save-dev”

then

“npm install intern –save-dev”

Then run your grunt intern task, and witness the new report.xml file created at the project root.

:)

WordPress + GoDaddy = Problems

So here’s something that took about 4 hours of my life to figure out.

Situation: You have a go-daddy hosted wordpress site. You have made a child theme for said wordpress site. Theme works great. Make updates to child theme style.css; nothing fancy, just some regular old css.

Reload style.css to appropriate directory via sftp. Go to site.

Problem: No new styles!!! And in fact, old, crappy styles!

Try: flushing cache. Multiple times. Clearing browser cache. Multiple times. Inspect network calls; see that the old styles.css is being loaded (though it doesn’t exist anymore). Delete styles.css and reupload. Check child theme permissions to make sure nothing funky is going on there. Copy entire styles.css and paste into theme options > custom css. Load stylesheet explicitly via the header.php file. Google like crazy. Start to panic because site you are working on is the blog of the VP of your company.

Solution: Activate a different theme. Pause. Reactivate the correct theme.

Freaking GoDaddy or WordPress or whoever!!! Whoever is at fault I hate you!

creating <a> with jquery not working in IE8

Another strange defect raised and resolved. This time dealing with jquery and IE8 (everyone’s favorite browser).

ISSUE: In IE8, the following code was not adding the desired anchor tag to the page :

var viewLink = new $("<a class="bold" href='javascript:void(0);'>").html("View More");
viewLink.insertAfter(domElement);

The document is already loaded, and the domElement I’m trying to insert this after is definitely on the page. What gives?

Solution:
It appears (and I haven’t found any documentation to support this except trial and error) that IE8 has a problem with creating an anchor tag that includes attributes. I haven’t tested this with anything other than an anchor tag yet, but it definitely was the issue for this one.
Here’s the working code:

var viewLink = new $("<a>").html("View More").attr("href","javascript:void(0);").addClass("bold");
viewLink.insertAfter(domElement);

Hope that helps!

Dojo Evented Gotcha

As I continue to work through the world of Dojo Dijits, I have run across another gotcha that I couldn’t find any documentation on and therefore only fixed by trial and error. So here’s my contribution to the world by adding this documentation to the internets.

Scenario: You create a custom component, extending the dojo Evented per the documentation:

define(["dojo/Evented"], function(Evented){
  var MyComponent = dojo.declare([Evented], {
    startup: function(){
      // once we are done with startup, fire the "ready" event
      this.emit("ready", {});
    }
  });
}

However, you build upon the component and end up with something like this:

define(["dojo/Evented"], function(Evented){
  var MyModel = dojo.declare([Evented], {
    CURRENT_INDEX_CHANGE:"onCurrentIndexChange",
    currentIndex:0,
    dispatchEvent: function(evt){
      this.emit(evt, {});
    },
    getCurrentIndex:function(){
      return this.currentIndex;
    },
    setCurrentIndex:function(n){
      if(n != this.currentIndex){
         this.currentIndex = n;
         this.dispatchEvent(this.CURRENT_INDEX_CHANGE);
      }
    }
  });
}

AND THEN, you end up getting this error in your browsers console:

TypeError: target.ownerDocument is undefined

ending in bafflement.😦

Reason:
“dispatchEvent” is used in dojo/on, which Evented extends, causing a conflict.

Solution! Rename your “dispatchEvent” function to something new, so you end up with:

define(["dojo/Evented"], function(Evented){
  var MyModel = dojo.declare([Evented], {
    CURRENT_INDEX_CHANGE:"onCurrentIndexChange",
    currentIndex:0,
    dispatchEventWTF: function(evt){
      this.emit(evt, {});
    },
    getCurrentIndex:function(){
      return this.currentIndex;
    },
    setCurrentIndex:function(n){
      if(n != this.currentIndex){
         this.currentIndex = n;
         this.dispatchEventWTF(this.CURRENT_INDEX_CHANGE);
      }
    }
  });
}

The end.

Building the Dojo Boilerplate

If you’re trying to use https://github.com/csnover/dojo-boilerplate and are getting the following error in the terminal when trying to build:
“-bash: build.sh: command not found”
You probably need to add “./” to “build.sh”. As someone not very Unix savvy this caused me hours of frustration.

So, to elaborate on the instructions under “Quick Start” found in the dojo-boilerplate github project –>

  1. Clone the repository using git clone –recursive.
    [My addition: Or click “clone in desktop” on the right hand side of the git hub page]
  2. Develop your project in src/ until it is amazing.
  3. Run build.sh, which will create an awesome optimised build in dist/.
    [My addition: Do the following:

    1. Open the Terminal (assuming you’re on a Mac – sorry, can’t really help if you’re not)
    2. cd to the boilerplate directory – specifically, you can type “cd” and then, drag the dojo-boilerplate directory into the terminal. This is a shortcut to cd to that directory. Alternatively, you can explicitly type out the directory path, as in “cd /User/uName/dojo-boilerplate”, where “/User/uName/dojo-boilerplate” is the path to your dojo-boilerplate.
    3. then type “./build.sh” into the terminal.
    4. you should then see a ton of logs showing that something is happening. Be patient, after about a minute, you will see “Build complete”. Now everything should be compiled in the “dist” folder that was created.
  4. Upload dist/ for millions of people the world over to enjoy.