Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: QUnit is not defined #12

Open
dlealv opened this issue Sep 12, 2021 · 3 comments
Open

Error: QUnit is not defined #12

dlealv opened this issue Sep 12, 2021 · 3 comments

Comments

@dlealv
Copy link

dlealv commented Sep 12, 2021

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

@andrewroberts
Copy link
Collaborator

Hi. Take a look at the test code here. QUnit is something you define in your own test code. And note the comment at the top about code ordering.

@dlealv
Copy link
Author

dlealv commented Sep 12, 2021

Thanks Andrew, this is the source code of my Tests.gs source file:

var Qunit = QUnitGS2.QUnit;

// HTML get function
function doGet() {
   QUnitGS2.init();

 /**
   * reviewBugInfo(jiraStatus, release, environment, rootCause, severity, status, resolution)
   * 
   */

  QUnit.module("reviewBugInfo tests");
  QUnit.test("Missing Mandatory fields", function( assert ) {
    assert.equal(reviewBugInfo("To Do", "release1", "env1", "rootCause1", "severity1", "status1", null), 
      null, "All mandatory fields have value");
  });

  // The following portion of the source code should not be changed

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

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

it uses the same logic as the source code you shared. The order of my files is the following:

Tests.gs
Code.gs

When I comment on the block for doing the testing

QUnit.module("reviewBugInfo tests");
  QUnit.test("Missing Mandatory fields", function( assert ) {
    assert.equal(reviewBugInfo("To Do", "release1", "env1", "rootCause1", "severity1", "status1", null), 
      null, "All mandatory fields have value");
  });

I got the following result, which is the same you in your tutorial, when there are not tests defined:

QUnit v2.9.2 for Google Apps Script
Hide passed tests
QUnit (Google Apps Script port); Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Tests completed in milliseconds.
assertions of passed failed.

Please advise,

Thanks,

David

@dlealv
Copy link
Author

dlealv commented Sep 12, 2021

I removed the semicolon at the end here, and it works:

QUnit.module("reviewBugInfo tests");
  QUnit.test("Missing Mandatory fields", function( assert ) {
    assert.equal(reviewBugInfo("To Do", "release1", "env1", "rootCause1", "severity1", "status1", null), 
      null, "All mandatory fields have value");
  }); 

The response, still indicates it is running QUnit 2.9.2

Thanks,

David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants