Warum wirft der Mokka im Browser ein globales Leck, das von einer URL erkannt wurde, aber nicht von einem unsicheren Pfad?

Ich erstelle eine Javascript-Bibliothek und möchte BDD verwenden. Daher probiere ich Mocha aus und kann es nicht zum Laufen bringen. Ich möchte, dass diese Bibliothek auf dem Client verwendet wird. Daher gehe ich davon aus, dass es sinnvoll ist, sie von einer durchsuchbaren URL aus auszuführen, sich in einem Kontext mit Webverbindung zu befinden und nicht nur eine Sandbox von einem unbekannten Pfad.

Hier ist die Dummy-Startpunktdatei test / test.foobar.js

var assert = chai.assert;

var foobar = {
  sayHello: function() {
    return 'Hello World!';
  }
};

describe('Foobar', function() {
  describe('#sayHello()', function() {
      it('should work with assert', function() {
      assert.equal(foobar.sayHello(), 'Hello World!');
    });

  });
});

Und hier ist die HTML-Seite, die den Test auslöst: test.html

<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Tests</title>
  <link rel="stylesheet" href="testing/mocha.css" />
  <script src="testing/jquery.js"></script>
  <script src="testing/mocha.js"></script>
  <script>mocha.setup('bdd')</script>
  <script src="testing/chai.js"></script>
  <script src="test/test.foobar.js"></script>
  <script> $(function() { mocha.run(); }) </script>
</head>
<body>
  <div id="mocha"></div>
</body>
</html>

wenn ich in chrom oder safari öffne

file:///Users/me/dev/sandbox/test.html

es funktioniert wie erwartet, Testdurchlauf ohne Fehler

wenn ich in chrom oder safari öffne

http://localhost/sandbox/test.html

Ich erhalte die folgende Fehlermeldung und der Test schlägt fehl

Error: global leak detected: script1339700707078
    at Runner.checkGlobals (http://localhost/sandbox/testing/mocha.js:3139:21)
    at Runner.<anonymous> (http://localhost/sandbox/testing/mocha.js:3054:44)
    at Runner.emit (http://localhost/sandbox/testing/mocha.js:235:20)
    at http://localhost/sandbox/testing/mocha.js:3360:14
    at Test.run (http://localhost/sandbox/testing/mocha.js:3003:5)
    at Runner.runTest (http://localhost/sandbox/testing/mocha.js:3305:10)
    at http://localhost/sandbox/testing/mocha.js:3349:12
    at next (http://localhost/sandbox/testing/mocha.js:3233:14)
    at http://localhost/sandbox/testing/mocha.js:3242:7
    at next (http://localhost/sandbox/testing/mocha.js:3192:23)

Kann jemand eine Erklärung und besser eine Lösung haben?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage