{"issue":{"created_at":"2011-12-08T16:02:24Z","state":"open","updated_at":"2011-12-08T22:51:30Z","comments":9,"user":{"gravatar_id":"70ca58d0e0e0eabbdb74d177417d09d7","id":375,"url":"https://api.github.com/users/augustl","avatar_url":"https://secure.gravatar.com/avatar/70ca58d0e0e0eabbdb74d177417d09d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"augustl"},"body":"Buster currently can't facilitate these types of tests:\r\n\r\n    require([\"my/file\"], function () {\r\n        buster.testCase(\"blah\", {\r\n            // ....\r\n        });\r\n    });\r\n\r\nThe difficulty lies in knowing when all the buster.testCase functions have called. body.onload is not enough, due to the async require. We need to know when the test run has \"finished\" so we can end the session in buster-capture-server and exit the \"buster test\" process in the terminal, so we can't just wait 10 seconds and hope all the tests have loaded by then..\r\n\r\nWe need some sort of counter to let buster know _before_ body.onload how many test cases that it expects to load. Suggestion:\r\n\r\n    buster.asyncTestCase(function (testCase) {\r\n        require([\"my/file\"], function () {\r\n            testCase(\"My test case\", {\r\n                // ....\r\n            });\r\n        });\r\n    });\r\n\r\nWith this model, buster knows at body.onload that there is one async test case that will be loaded in the future. It can wait for the passed \"testCase\" (which is just a wrapped buster.testCase) function to be called and know that if it isn't called it can timeout, and so on.","assignee":{"gravatar_id":"6e7ddb6784d284c385f3f0f307ebf90d","id":32871,"url":"https://api.github.com/users/cjohansen","avatar_url":"https://secure.gravatar.com/avatar/6e7ddb6784d284c385f3f0f307ebf90d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"cjohansen"},"id":2489331,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"number":15,"title":"Async test cases in browser, useful for AMD, RequireJS","html_url":"https://github.com/busterjs/buster/issues/15","closed_at":null,"url":"https://api.github.com/repos/busterjs/buster/issues/15","milestone":{"created_at":"2011-12-07T21:34:11Z","state":"open","closed_issues":1,"due_on":null,"creator":{"gravatar_id":"70ca58d0e0e0eabbdb74d177417d09d7","id":375,"url":"https://api.github.com/users/augustl","avatar_url":"https://secure.gravatar.com/avatar/70ca58d0e0e0eabbdb74d177417d09d7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"augustl"},"number":1,"description":"","title":"1.0 release","open_issues":12,"url":"https://api.github.com/repos/busterjs/buster/milestones/1"}},"action":"created","comment":{"created_at":"2011-12-08T22:51:30Z","updated_at":"2011-12-08T22:51:30Z","user":{"gravatar_id":"238dabe9f0d4da12c85c694811bb28ce","id":515722,"url":"https://api.github.com/users/geddesign","avatar_url":"https://secure.gravatar.com/avatar/238dabe9f0d4da12c85c694811bb28ce?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"geddesign"},"body":"@cjohansen understood. Arriving at the ideal syntax with an extension sounds reasonable. And in the meantime your `run()` proposal looks pretty good, so long as you only need to do it once per file. So this:\r\n\r\n```javascript\r\ndescribe(\"Something\", function (run) {\r\n    require([\"something\"], function (something) {\r\n        run(function () {\r\n            it(\"does things\", function () {});\r\n            it(\"does more things\", function () {});\r\n            describe('when hungry', function(){\r\n                  it(\"does other things\", function () {});\r\n            });\r\n        });\r\n    });\r\n});\r\n``` \r\n\r\nand not this:\r\n\r\n```javascript\r\ndescribe(\"Something\", function (run) {\r\n    require([\"something\"], function (something) {\r\n        run(function () {\r\n            it(\"does things\", function () {});\r\n        });\r\n    });\r\n\r\n    require([\"something\"], function (something) {\r\n        run(function () {\r\n            it(\"does more things\", function () {});\r\n        });\r\n    });\r\n\r\n     require([\"something\"], function (something) {\r\n        run(function () {\r\n            describe('when hungry', function(){\r\n                  it(\"does other things\", function () {});\r\n            });\r\n      });\r\n});\r\n``` \r\n\r\nYou get the idea. A single `run()` would be totally fine. ","id":3071519,"url":"https://api.github.com/repos/busterjs/buster/issues/comments/3071519"}}