Giter VIP home page Giter VIP logo

qunitgs2's People

Contributors

andrewroberts avatar artofthesmart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qunitgs2's Issues

Testing procedures calling helper functions or other procedures

Hi,

I try to test a quite long procedure onClick, see below, (I mean here a procedure as understood in JS: returning nothing, just writing calculation results out into a Google sheet) that consists of many other sub-procedures or functions.

Whereas testing a single function (a function as understood in JS: returning something; some of these functions don't take an input) or procedure (some of them take an input) all works fine and according to instructions from: http://qunitgs2.com/.

However tests for that long procedure (using successfully tested single functions/procedures) don't work: after depolying the test code as a web app and clicking latest code (everything exactly as by previously described code tests) a html tab pops out with a proper header, etc, but no tests run. What is more the test code doesn't call the tested procedure at all. However, it was calling tested single functions/procedures; they run and changed the sheet they worked on. Moreover, they don't need to be included in assert object.

Does it mean that it's impossible to test such procedures: being a set of other functions or procedures? Or is it something else?

Here the test suit:

let QUnit = QUnitGS2.QUnit;

function doGet() {
   QUnitGS2.init();

   QUnit.module('Script test');

   QUnit.test('onClick function', function(assert) {
       //when
       onClick();  // At the end it writes a figure in a sheet's G11 cell. 
       //then
       assert.equal(mainSheet.getRange('G11').getValue(), '2.10970231', 'provides correct total balance after running script');
   });

   QUnit.start();
   return QUnitGS2.getHtml();
}

function getResultsFromServer() {
   return QUnitGS2.getResultsFromServer();
}

Redeploy webapp on add/modify tests

I'm new to developing with GAS and QUnit. I was trying out the sample code provided. Whenever I make changes to the code, I do not see the changes getting reflected on the webpage - unless I redeploy the app. Is this normal or is there another alternative to review the changes?

// HTML get function
function doGet() {

   QUnitGS2.init();

  // Tests
  QUnit.module("Basic tests");

  QUnit.test("simple numbers", function( assert ) {
    assert.equal(divideThenRound(10, 2), 5, "whole numbers");

    assert.equal(divideThenRound(10, 4), 2.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 1.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 3.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 2.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 1.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 3.5, "decimal numbers");

    assert.equal(divideThenRound(10, 4), 2.5, "decimal numbers");

   QUnit.start();
   return QUnitGS2.getHtml();
}

// Retrieve test results when ready.
function getResultsFromServer() {
   return QUnitGS2.getResultsFromServer();
}

Check for globals

This didn't work in the original v1 version, can it be fixed in QUnitGS2.

Error: QUnit is not defined

First of all, thank you for creating this tool. I am following the instructions you provided:
http://qunitgs2.com/examples/step-by-step-tutorial

I was able to install version 23 using the ID you provided.

When I enter the code for specifying the test cases I am getting the following error:

ReferenceError: QUnit is not defined (line 17, file "Tests")

The line refers to the following portion of the source code:

QUnit.module("reviewBugInfo tests");

This is the QUnit version: QUnit v2.9.2 for Google Apps Script

I was not able to find this error on the internet.

Please advise,

Thanks

Totals not showing in test banner for "modules" tests

The "All tests finished" callback doesn't get called, so no totals are available to display in the banner.

setTimeout() is used a lot in the tests, so presumably, as this is stubbed out the setTimeout() is never getting called to indicate the end of the tests (various tests come back with zero results).

Similar thing is seen in step tests.

Remove need for getResultsFromServer()

Although the doGet() runs the test functions, the actual results are returned from the original QUnit library by various callback functions as JSON strings. These callbacks don't run until after the original doGet function has finished, so the doGet simply constructs the skeleton of the UI and the callbacks store the results in user cache ready to be retrieved by an async call from within the client-side UI. The success handler of this client-side call constructs the HTML to display the test results in the UI.

Because the client-side function - window.onload - is making a server-side call from within a library that getResultsFromServer() function has to be a global in the script project calling the library.

The QUnitGS2 library would need to be copied into the calling script to get around this at the moment, but a deeper dive into the original QUnit library may find a way around it.

Tests with uncaught exceptions disappear

Repro: Run a test that throws an uncaught exception, for example:

var QUnit = QUnitGS2.QUnit;

function doGet() {
   QUnitGS2.init();

   // Just to demonstrate that QUnitGS2 plumbing is hooked up correctly.
   QUnit.test("simple numbers", function( assert ) {
     assert.equal(1 + 1, 2, "addition");
   });

   QUnit.test("exception", function( assert ) {
     Logger.log("before exception");
     throw "uh oh";
     Logger.log("after exception");
   });

   QUnit.start();
   return QUnitGS2.getHtml();
}

function getResultsFromServer() {
   return QUnitGS2.getResultsFromServer();
}

I'm using the V8 runtime; not sure if that matters.

Expected: something shows up in the results page, or at least in the log that indicates an exception was thrown.

Actual: no indication in the UI that the test was even defined:

html screenshot

logs screenshot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.