Comments (12)
To test asynchronous code you can use the JS Unit Mock Timeouts.
See this previous thread discussing it:
http://groups.google.com/group/js-test-driver/browse_thread/thread/13...
Or check out this Google Testing Blog entry:
http://googletesting.blogspot.com/2007/03/javascript-simulating-time-...
This approach works by overriding the setTimeout and setInterval
functions, and giving you a clock you can explicitly control in your
tests.
The main benefit of this approach is all your tests run instantly, you don't
actually
need to wait for the timeout to complete! And there is no need for a timeout,
which
could cause intermittent failures (due to a slow test machine for example.)
Original comment by [email protected]
on 30 Aug 2009 at 8:32
from js-test-driver.
Thanks for the hint into this direction.
Because I always used QUnits possibilities to test asynchronous call, I never
thought
about simply mocking them to create a synchronous sequence of calls. Even
though this
seems quite intuitively the right thing to do now, I just never thought of it.
The
jsUnit Mock Timeouts are a great addition to this.
This should cover everything I need to test using js-test-driver.
I like js-test-driver better every minute ;)
greetings Jakob
Original comment by [email protected]
on 30 Aug 2009 at 11:08
from js-test-driver.
I second the desire to get support for asynchronous tests. I've been using the
JsUnit
mocker, and it works like a charm. Maybe it should just be rolled into
JsTestDriver?
Original comment by [email protected]
on 20 Oct 2009 at 4:07
from js-test-driver.
I noticed that there is an implementation for asynchronous tests in the latest
JsTestDriver trunk. I modified the QUnit adapter to support stop(), start(),
and asyncTest().
The modified adapter works as of revision r364 if the patch from issue 125 is
applied.
Original comment by [email protected]
on 9 Jul 2010 at 11:19
Attachments:
from js-test-driver.
Is the revision in Comment #4 correct? I looked at the patch and it doesn't
seem to match up with the underlying source. In fact I can't find any version
of that file (QUnitAdapter.js) that lines up with the patch. Did it come from
a branch?
I ask this because I would love to use JSTD but I need to test async calls. It
is for doing integration tests rather than unit tests, but I still need a
similar framework.
Original comment by [email protected]
on 11 Sep 2010 at 6:06
from js-test-driver.
Never mind comment #5. I upgraded to the head (r688) and the patch worked fine
(assuming that the patch from issue 125 is applied first)
Original comment by [email protected]
on 11 Sep 2010 at 6:16
from js-test-driver.
I'm sorry; I must have completely spaced when I wrote the revision number in
comment #4.
Original comment by [email protected]
on 11 Sep 2010 at 7:33
from js-test-driver.
I created a new plugin called QUnitTestRunnerPlugin
<http://github.com/jivesoftware/QUnitTestRunnerPlugin> that I believe provides
more robust support for running asynchronous tests with JsTestDriver and QUnit
than QUnitAdapter does. It also does not require patching JsTestDriver. We
are using QUnitTestRunnerPlugin to test production code at Jive Software.
Original comment by [email protected]
on 11 Sep 2010 at 10:31
from js-test-driver.
The implementation of AsyncTestCase in release 1.2.2 works, just not as
advertised in its current docs at
http://code.google.com/p/js-test-driver/wiki/AsyncTestCase. Presumably the
version in svn trunk works as described on that page.
Essentially, the 1.2.2 version passes a pool object to the tests in an
AsyncTestCase rather than a queue object.
Original comment by [email protected]
on 9 Dec 2010 at 4:17
from js-test-driver.
See also issue 171, which more-or-less duplicates this one.
Original comment by [email protected]
on 9 Dec 2010 at 4:27
from js-test-driver.
Fully release in 1.3.0
Original comment by [email protected]
on 14 Feb 2011 at 4:39
- Changed state: Fixed
from js-test-driver.
I extended the adapter to add/update the methods to current QUnit trunk (as of
15/09/11). Includes the patch above, adding QUnit async methods with some
bugfixes.
You can find it here: https://github.com/progmedia/QUnit-to-JsTestDriver-adapter
Feel free to fork it and suggest patches.
I'll soon be updating this repo with some scripts i'm working on to add support
for external HTML fixtures, accessible from the DOM in tests, something I find
sorely lacking in Js-Test-Driver.
Original comment by [email protected]
on 16 Sep 2011 at 1:15
from js-test-driver.
Related Issues (20)
- Eclipse test result order
- [deleted issue]
- charset add a line to config file
- Enable reading files within jars HOT 2
- The eclipse plugin cannot be use. HOT 1
- JSTD runs very slowly when Chrome slave runs in a "background" tab HOT 1
- jstd tries to serve folder "components.js" as a file
- Multiple files with same name in different locations loaded in wrong order
- jstestdriver.conf as unicode won´t load
- Eclipse plugin is not using last 1.3.5 version
- Cannot mirror update site
- Intellij Cardea 132.839 can't run test, exception is thrown
- Is it possible to force to specific DOC-type/document mode?
- No browsers available, yet actions only when run from Jenkins.
- Using webjars, possible?
- loading file not from load config HOT 3
- executing test cases from command line producing error
- TestCase error after use /*DOC: */
- Enter one-line summary-Ammar Allia Partagé
- Can't load moment-with-langs.min.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-test-driver.