Question about jqUnit for non-kettle apps...

Tony Atkins tony at raisingthefloor.org
Fri May 9 13:16:22 UTC 2014


Hi, All:

To partially answer my own question, if I just start with the node-jqUnit
documentation <https://github.com/fluid-project/node-jqUnit>, I can do what
I need as illustrated in this example:

var fluid = require("infusion");
>
> var jqUnit = fluid.require("jqUnit");
>
> var setup = 0;
>
>
>> console.log("setup");
>
> var setup = 1;
>
>
>> jqUnit.module("Search API Tests");
>
>
>> jqUnit.onAllTestsDone.addListener(function() {
>
>     var setup = -1;
>
>     console.log("teardown");
>
> });
>
>
>> jqUnit.test("My test case", function() {
>
>         jqUnit.assertEquals("Setup has been run, but shutdown has not.",
>> setup, 1);
>
>     }
>
> );
>
>
The setup is done synchronously ahead of time and the teardown is executed
after all tests are run.  I would still like to know what can be safely
inserted into the testDef sequence used by the fluid test runner, and how
to avoid running kettle, but for now I can at least write my tests.

Cheers,



Tony


On Fri, May 9, 2014 at 2:11 PM, Tony Atkins <tony at raisingthefloor.org>wrote:

> Hi, All:
>
> I am working on writing tests for things other than Kettle, such as
> express and couchdb.  I have been using the following URLs as my starting
> template:
>
> https://github.com/GPII/universal/blob/master/tests/all-tests.js
> https://github.com/GPII/universal/blob/master/tests/DevelopmentTests.js
>
> After a quick tour from Antranig, I managed to get to the point where I
> could run a sanity check (1=1) test, but in doing so I noticed that there
> are a quite a few apparent unstated assumptions.  You must have certain
> structures to use the test harness, and the errors returned if you lack
> these things are not at all intuitive.
>
> Setting that aside, the key point is that I have two basic goals that I
> have not yet been able to achieve:
>
> *1.  I do not want to run kettle.*
>
> I either want to know how not to run kettle at all, or how to create a
> custom server.  If you omit the server from your test configuration, the
> tests won't run at all.  I tried mocking kettle.server and using that
> instead of kettle, but was unable to get that working either (the errors
> were similar to those below, about "apply" methods on undefined).
>
> *2.  I want to call my own setup and teardown code before and after my
> tests.*
>
> I would like to instantiate a pouchdb instance (for example) and then
> start express before running my tests, and then tear down both after all
> tests are run.  I can see that we have passthroughs to some qunit
> functions, but not their setup and teardown functions.
>
> I tried calling my own gpii-registered functions from testDefs.sequence,
> that seems to expect a function that is derived from a particular prototype
> that includes an "apply" function:
>
> TypeError: Object #<Object> has no method 'apply'
>
>     at Object.fluid.invokeGlobalFunction
>> (/Users/duhrer/Source/rtf/rtf-terms-registry/express/node_modules/infusion/src/framework/core/js/Fluid.js:943:25)
>
>
> I have been unable to find a good example or documentation where anything
> like this is done, and could use some help.
>
> If you'd like to see the code, it's here, and I have left it broken for
> now:
>
> https://github.com/the-t-in-rtf/common-terms-registry
>
> Don't worry about the million other things that I swear I am working to
> clean up.  Just navigate to the "express" directory and run "node
> tests/all-tests.js" to see the error.
>
> Any ideas about what's wrong or (even better) suggestions about a
> reasonable way to achieve the two goals (not running kettle, passing in
> setup/teardown functions) would be greatly appreciated.
>
> Thanks,
>
>
> Tony
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.idrc.ocad.ca/pipermail/fluid-work/attachments/20140509/b63ca3ac/attachment.htm>


More information about the fluid-work mailing list