1

I have been trying to use QUnit to test my code but have been getting this error: "Library with identifier QUnit is missing (perhaps it was deleted, or maybe you don't have read access?)."

I am sure I have installed it correctly with the correct key.

My google account is a G Suite for Education Account that's been set up by my company, I have two different Education accounts with them. Both accounts are in different organisational units from each other. One of them can run QUnit with no issues but I need it to work on the account that is throwing the error.

I took the following steps too add QUnit to my project:

  1. Went onto Libraries and entered the code "MxL38OxqIK-B73jyDTvCe-OBao7QLBR4j"

  2. Selected version 4.

  3. Published as a Web App and then selected "Test web app for your latest code" to view the results.

  4. I am then presented with the error message on a new tab.

When I try these same steps on my Personal Google Account as well there seems to be no issues.

Below is my QUnit code, if you can see where I've went wrong or if there are any G Suite Settings that should be changed that you know of that would be a great help.

function doGet( e ) {
  QUnit.urlParams( e.parameter );
  
  QUnit.config({
    title: "Unit tests for my project" 
  });
  QUnit.load( tests );
  return QUnit.getHtml();
};


function tests() {
  addEqual();
  addNotEqual();
  multiplyEqual();
  multiplyNotEqual();
}


function addEqual() {
  test("Add number to number", function() {
    equal(addNumbers(), 5, 'It worked!');
  });
}

function addNotEqual() {
  test("Add number to number", function() {
    equal(addNumbers(), 8, 'It worked!');
  });
}

function multiplyEqual() {
  test("Multiply Number with a Number", function() {
    equal(multiply(), 6, 'It Worked!');
  });
}

function multiplyNotEqual() {
  test("Multiply Number with a Number", function() {
    notEqual(multiply(), 9, 'It Worked!');
  });
}
TheMaster
  • 45,448
  • 6
  • 62
  • 85

2 Answers2

5

Summary:

So far, the easiest way to solve the issue is not to use the library feature at all, but directly copy paste files from the library's source. Note that all .gs and .html files should be included as separate files in your project. Other ways to solve includes various versions of deleting the calling script project and re-adding each library in a new project. On the library developer side, it includes saving a new version of the library.

Possible Cause(s):

Possible Solution(s):

Currently Open Issue Trackers:

Closed Trackers(for research):

Related:

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • This sounds like a helpful solution for now! Sorry but I am a novice with Google Scripts. How would I find the libraries source to get these files? – Stephen McBride Sep 18 '20 at 10:49
  • @StephenMcBride It's usually in github. Copy paste all the files there. – TheMaster Sep 18 '20 at 14:02
  • Hi I am very sorry for my late message, I am still unsure how to do this. I have found the github for Qunit: https://github.com/qunitjs/qunit. But I am unsure what files I am to copy over. Is there be any chance you could walk me through this? – Stephen McBride Oct 06 '20 at 14:55
  • @StephenMcBride That's the main JavaScript module. You can't use that. Your library version is basically from [here](https://github.com/simula-innovation/qunit/tree/gas/gas). Someone also created [qunit2](https://github.com/artofthesmart/QUnitGS2). You'll basically need all .gs and .html files from any of those. – TheMaster Oct 06 '20 at 15:09
0

I followed the steps provided on the question, using my G Suite for Business account and the default runtime (Chrome V8) but I got another error

ReferenceError: test is not defined (line 21, file "Code")

After replacing test(...) by QUnit.test(...).The web page was correctly displayed.

I don't think that your G Suite account administrator bloqued your account to access receive files from outside your organization because you are able to see the library title and versions. There should be something that you missed to include in the question. Try to create a new project from scratch following the steps included in the question.

Resources

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Thank you for your answer, I followed what you have said but still have the same issue. To correct myself I am using a G Suite Account for Education if that makes a difference. – Stephen McBride Sep 10 '20 at 08:24