{"action":"closed","issue":{"url":"https://api.github.com/repos/aurelia/benchmarks/issues/2","labels_url":"https://api.github.com/repos/aurelia/benchmarks/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/benchmarks/issues/2/comments","events_url":"https://api.github.com/repos/aurelia/benchmarks/issues/2/events","html_url":"https://github.com/aurelia/benchmarks/issues/2","id":63384975,"number":2,"title":"Reference benchmark.js via JSPM or pass in as parameter to the constructor","user":{"login":"zewa666","id":2861414,"avatar_url":"https://avatars.githubusercontent.com/u/2861414?v=3","gravatar_id":"","url":"https://api.github.com/users/zewa666","html_url":"https://github.com/zewa666","followers_url":"https://api.github.com/users/zewa666/followers","following_url":"https://api.github.com/users/zewa666/following{/other_user}","gists_url":"https://api.github.com/users/zewa666/gists{/gist_id}","starred_url":"https://api.github.com/users/zewa666/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zewa666/subscriptions","organizations_url":"https://api.github.com/users/zewa666/orgs","repos_url":"https://api.github.com/users/zewa666/repos","events_url":"https://api.github.com/users/zewa666/events{/privacy}","received_events_url":"https://api.github.com/users/zewa666/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-21T10:06:19Z","updated_at":"2015-03-21T19:03:03Z","closed_at":"2015-03-21T19:03:03Z","body":"I've seen that your App requires Benchmark.js manually in the index.html. The problem that results doing it this way is that the ES6 classes (like MicroTest) depend on a global Object. Now within your Test-UI thats no problem, but I was experimenting to implement a Console-UI with NodeJS, so I could automate the test process. Now that global object makes ones life pretty hard :)\r\n\r\nFor the sake of testing I just wen't with passing Benchmark as a parameter to the MicroTest constructor.\r\n\r\nBelow what I did so far:\r\n\r\n```\r\n// Preqreq\r\nnpm install es6-module-loader (could have alternatively also used the JSPM edition)\r\nnpm install request\r\n\r\n* Modified app/performanceTest/microTest.js class constructor to accept Benchmark as 2nd parameter\r\nconstructor(name, Benchmark) {\r\n  super(name);\r\n  this.Benchmark = Benchmark;\r\n   ...\r\n}\r\n\r\n// Code of console ui\r\nvar request = require('request');\r\n// declare globally because Benchmark doesn't like JSPM :)\r\nBenchmark = require('../lib/benchmark');\r\nvar System = require('es6-module-loader').System;\r\nSystem.baseURL = \"file:C:/aurelia/benchmarks/\";\r\nSystem.transpiler = 'babel';\r\n\r\nrequest('http://localhost:8080/api/tests', function (error, response, body) {\r\n  if (!error && response.statusCode == 200) {\r\n    var microTests = JSON.parse(body).micro;\r\n\r\n    System.import('app/performanceTest/microTest').then(function (microTest) {\r\n      microTests.forEach(function (tName) {\r\n        var test = new microTest.MicroTest(tName, Benchmark);\r\n        test.run().then(function (result) {\r\n          console.log('Test \"' + tName + '\": ' + result._elapsed);\r\n        });\r\n      });\r\n    });\r\n  }\r\n});\r\n```"}}