quintel / etmoses

Online decision support tool to create local energy situations for neighbourhoods, cities and regions with a time resolution of 15 minutes created and maintained by Quintel – Not maintained
https://moses.energytransitionmodel.com
MIT License
11 stars 3 forks source link

Using a test framework for Javascript #1449

Closed grdw closed 7 years ago

grdw commented 7 years ago

I am currently writing code for the Topology Editor however - as @ChaelKruip pointed out - there are no Javascript specs. It sounds lovely and I know how to write tests in QUnit. However considering we're having a Rails project it might also be worthwhile to checkout teaspoon.

What is your opinion about this matter? @antw

antw commented 7 years ago

I think Jasmine and Mocha are quite popular in the JS world, but I don't know very much about either. I used QUnit and Jasmine a few years ago, but it's been so long that I don't think my opinion counts for much. 😆

Perhaps we might research the different options? Teaspoon looks pretty cool as well

grdw commented 7 years ago

I have some experience with QUnit and that's it. But I used it for a pretty vanilla Javascript application.

I'll research some options and present my findings. 👍 Teaspoon does look really cool. I'll try some of them and see what 'works' nice and easy.

antw commented 7 years ago

http://stateofjs.com/2016/testing/

grdw commented 7 years ago

MochaJS looks promosing. For the basic fact that you can run it from the browser 👍 which is really cool. I also know QUnit can do that. I'm only a bit unaware about the whole process of writing specs in Javascript. Will it be something like this (to put it in perspective):

// Quick code example:
describe("d3 topology chart", function () {
  before(function() {
    this.topologyChart = Topology.Base.new("body", { name: "HV" });
  });

  test("it renders", function () { 
    this.topologyChart.draw();

    ok($("svg").length > 0);
  });

  afterEach(function () {
    $("body").html("");
  });
});