Testing and cmd?

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?

1 Like

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) {
  } 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).


Hey Emanuele,

Thanks for reaching out.

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

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.

Using Firefox 87.0 on Windows 10

the above bookmarklet doesn’t work:

TypeError: existingConsole is null

Alternative approach:

Seeing as glitch automatically restarts the node.js server whenever the code changes tests can be run with something like the following:

if (developmentMode) {

Assertion errors should show up in the error logs.

Hi there @olleicua!
This thread is from 4 years ago! There is now an inbuilt console in Glitch, assuming that’s what you want. Learn more using this article:

Hope this helps :slight_smile:

1 Like