Testing and cmd?


#1

Newbie here,

Kind of curious how one would go about using Jest or any kind of TDD in Glitch.
I’ve used Cloud9 on most of my projects. Glitch is cool, but how do I get access to the cmd?


#2

hi Zachary,

Access to the console is still experimental, we are still figuring out how we’re going to offer access to the feature. In the meantime, you can use this bookmarklet (put it in your bookmark bar):

javascript:(function () {
  var existingConsole = $(".custom-console");
  if (existingConsole.length > 0) {
    existingConsole.remove();
  } else {
    var consoleDiv = $( '<div id="activity-log" class="custom-console" style="overflow: hidden;">' );
    var url = `https://api.${window.location.host}/${application.currentProject().name()}/console/${application.currentUser().persistentToken()}/`;
    consoleDiv[0].innerHTML = `<iframe src="${url}" style="width: 100%; height: 100%" />`;
    $("#activity-log").after( consoleDiv );
  }
})()

As for testing, I am writing a simple app to learn CoffeeScript and Mithril, and I use Mocha for testing and Istanbul for code coverage. It works like a charm: https://glitch.com/edit/#!/coffee-mithril

Feel free to remix it! Through the console, you can run sh/test to run the tests and sh/coverage to evaluate the code coverage. Then you can see the coverage report in https://coffee-mithril.glitch.me/coverage (protected by a password that you can set in .env).


#3

Hey Emanuele,

Thanks for reaching out.

How would I go about running the tests with your code?


#4

Hi Zachary,

from the console, that you can open using the bookmarklet provided above, you can run sh/test.

Please notice that you can only open the console on projects you own.