Hi,
This is the current API for using Litmus in the browser (from the
https://github.com/usenode/litmus.js/tree/easy-clientside-install
branch):
require(['browser', 'litmus'], function (browser, litmus) {
browser.run(new litmus.Test('example test', function () {
this.ok(true, 'an assertion');
}));
});
This could be simpler. I'd prefer the browser dist to know which test
runner to use, like the command line.
require(['litmus'], function (litmus) {
new litmus.Test('example test', function () {
this.ok(true, 'an assertion');
}).run();
});
Thoughts?
Richard
Paths passed to Node's require must be as they appear in an NPM package,
with the exception of the main module if you specify a "main" in your
package.json:
http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders
When running in node, the only user-facing parts are the litmus module and
the command line runner (i.e. the "litmus" command). The litmus module is
used for specifying (i.e. exporting) tests and suites and the command-line
runner is used to run them.
In the browser, I'd like tests to be specified in the same way (i.e.
creating litmus.Test and litmus.Suite objects), but the way they are
loaded, executed and reported is necessarily different.
I'm not against changing modules for the browser. In Spectrum, for example,
I think we'll have to statically inject a template loader that works in the
browser when we do the AMD conversion. OTOH, I'm not sure if there's a case
for it here. I think I like the following best because it's not too magic:
require(['litmus', 'litmus/browser'], function (litmus, browser) {
browser.run(new litmus.Test('example test', function () {
this.is(1 + 1, 2, '1 + 1 is 2');
});
});
It would be nice if the source for the litmus/browser module doesn't have
to live in litmus/browser.js in the source package (am I being picky?). I
wish the package.json contained a module root rather than a main module.
I guess most people with any moderately sized project would have something
like:
require(['litmus/browser', './my/test/suite'], function (browser,
suite) {
browser.run(suite);
});
Regards
Tom
On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com> wrote:
> Hi,
>
> This is the current API for using Litmus in the browser (from the
> https://github.com/usenode/litmus.js/tree/easy-clientside-install
> branch):
>
> require(['browser', 'litmus'], function (browser, litmus) {
> browser.run(new litmus.Test('example test', function () {
> this.ok(true, 'an assertion');
> }));
> });
>
> This could be simpler. I'd prefer the browser dist to know which test
> runner to use, like the command line.
>
> require(['litmus'], function (litmus) {
> new litmus.Test('example test', function () {
> this.ok(true, 'an assertion');
> }).run();
> });
>
> Thoughts?
>
> Richard
>
I'm happy to optimise the API later, there is a risk it could become a bit magic. Does this mean we move everything from lib/ to litmus/ ? Richard On 1 Nov 2011, at 21:57, Tom Yandell <tom@yandell.me.uk> wrote: > Paths passed to Node's require must be as they appear in an NPM package, with the exception of the main module if you specify a "main" in your package.json: > > http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders > > When running in node, the only user-facing parts are the litmus module and the command line runner (i.e. the "litmus" command). The litmus module is used for specifying (i.e. exporting) tests and suites and the command-line runner is used to run them. > > In the browser, I'd like tests to be specified in the same way (i.e. creating litmus.Test and litmus.Suite objects), but the way they are loaded, executed and reported is necessarily different. > > I'm not against changing modules for the browser. In Spectrum, for example, I think we'll have to statically inject a template loader that works in the browser when we do the AMD conversion. OTOH, I'm not sure if there's a case for it here. I think I like the following best because it's not too magic: > > require(['litmus', 'litmus/browser'], function (litmus, browser) { > browser.run(new litmus.Test('example test', function () { > this.is(1 + 1, 2, '1 + 1 is 2'); > }); > }); > > It would be nice if the source for the litmus/browser module doesn't have to live in litmus/browser.js in the source package (am I being picky?). I wish the package.json contained a module root rather than a main module. > > I guess most people with any moderately sized project would have something like: > > require(['litmus/browser', './my/test/suite'], function (browser, suite) { > browser.run(suite); > }); > > Regards > > Tom > > On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com> wrote: > Hi, > > This is the current API for using Litmus in the browser (from the > https://github.com/usenode/litmus.js/tree/easy-clientside-install > branch): > > require(['browser', 'litmus'], function (browser, litmus) { > browser.run(new litmus.Test('example test', function () { > this.ok(true, 'an assertion'); > })); > }); > > This could be simpler. I'd prefer the browser dist to know which test > runner to use, like the command line. > > require(['litmus'], function (litmus) { > new litmus.Test('example test', function () { > this.ok(true, 'an assertion'); > }).run(); > }); > > Thoughts? > > Richard >
Ugh, is this the pattern? I guess I could get used to it :-s. I guess the less we modify the packages during the AMD conversion the better. Tom On 03/11/2011 09:32, Richard Hodgson wrote: > I'm happy to optimise the API later, there is a risk it could become a > bit magic. > > Does this mean we move everything from lib/ to litmus/ ? > > Richard > > On 1 Nov 2011, at 21:57, Tom Yandell <tom@yandell.me.uk > <mailto:tom@yandell.me.uk>> wrote: > >> Paths passed to Node's require must be as they appear in an NPM >> package, with the exception of the main module if you specify a >> "main" in your package.json: >> >> http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders >> >> When running in node, the only user-facing parts are the litmus >> module and the command line runner (i.e. the "litmus" command). The >> litmus module is used for specifying (i.e. exporting) tests and >> suites and the command-line runner is used to run them. >> >> In the browser, I'd like tests to be specified in the same way (i.e. >> creating litmus.Test and litmus.Suite objects), but the way they are >> loaded, executed and reported is necessarily different. >> >> I'm not against changing modules for the browser. In Spectrum, for >> example, I think we'll have to statically inject a template loader >> that works in the browser when we do the AMD conversion. OTOH, I'm >> not sure if there's a case for it here. I think I like the following >> best because it's not too magic: >> >> require(['litmus', 'litmus/browser'], function (litmus, browser) { >> browser.run(new litmus.Test('example test', function () { >> this.is <http://this.is>(1 + 1, 2, '1 + 1 is 2'); >> }); >> }); >> >> It would be nice if the source for the litmus/browser module doesn't >> have to live in litmus/browser.js in the source package (am I being >> picky?). I wish the package.json contained a module root rather than >> a main module. >> >> I guess most people with any moderately sized project would have >> something like: >> >> require(['litmus/browser', './my/test/suite'], function (browser, >> suite) { >> browser.run(suite); >> }); >> >> Regards >> >> Tom >> >> On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com >> <mailto:rightaboutnow@gmail.com>> wrote: >> >> Hi, >> >> This is the current API for using Litmus in the browser (from the >> https://github.com/usenode/litmus.js/tree/easy-clientside-install >> branch): >> >> require(['browser', 'litmus'], function (browser, litmus) { >> browser.run(new litmus.Test('example test', function () { >> this.ok(true, 'an assertion'); >> })); >> }); >> >> This could be simpler. I'd prefer the browser dist to know which test >> runner to use, like the command line. >> >> require(['litmus'], function (litmus) { >> new litmus.Test('example test', function () { >> this.ok(true, 'an assertion'); >> }).run(); >> }); >> >> Thoughts? >> >> Richard >> >>
I'd rather we avoid having a different structure between CJS and AMD formats of the code, it means having to update dependency paths in modules during the conversion between each format. Thinking about it...not everything has to be in a litmus/ dir, only the modules we expect people to depend on. Whilst Npm doesn't support a 'main' directory anymore, having a convention for modules we consider public is probably a Good Thing. Richard. On 3 November 2011 09:55, Tom Yandell <tom@yandell.me.uk> wrote: > Ugh, is this the pattern? I guess I could get used to it :-s. I guess the > less we modify the packages during the AMD conversion the better. > > Tom > > On 03/11/2011 09:32, Richard Hodgson wrote: > > I'm happy to optimise the API later, there is a risk it could become a bit > magic. > Does this mean we move everything from lib/ to litmus/ ? > Richard > On 1 Nov 2011, at 21:57, Tom Yandell <tom@yandell.me.uk> wrote: > > Paths passed to Node's require must be as they appear in an NPM package, > with the exception of the main module if you specify a "main" in your > package.json: > http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders > When running in node, the only user-facing parts are the litmus module and > the command line runner (i.e. the "litmus" command). The litmus module is > used for specifying (i.e. exporting) tests and suites and the command-line > runner is used to run them. > In the browser, I'd like tests to be specified in the same way (i.e. > creating litmus.Test and litmus.Suite objects), but the way they are loaded, > executed and reported is necessarily different. > I'm not against changing modules for the browser. In Spectrum, for example, > I think we'll have to statically inject a template loader that works in the > browser when we do the AMD conversion. OTOH, I'm not sure if there's a case > for it here. I think I like the following best because it's not too magic: > require(['litmus', 'litmus/browser'], function (litmus, browser) { > browser.run(new litmus.Test('example test', function () { > this.is(1 + 1, 2, '1 + 1 is 2'); > }); > }); > It would be nice if the source for the litmus/browser module doesn't have to > live in litmus/browser.js in the source package (am I being picky?). I wish > the package.json contained a module root rather than a main module. > I guess most people with any moderately sized project would have something > like: > require(['litmus/browser', './my/test/suite'], function (browser, suite) > { > browser.run(suite); > }); > Regards > Tom > On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com> wrote: >> >> Hi, >> >> This is the current API for using Litmus in the browser (from the >> https://github.com/usenode/litmus.js/tree/easy-clientside-install >> branch): >> >> require(['browser', 'litmus'], function (browser, litmus) { >> browser.run(new litmus.Test('example test', function () { >> this.ok(true, 'an assertion'); >> })); >> }); >> >> This could be simpler. I'd prefer the browser dist to know which test >> runner to use, like the command line. >> >> require(['litmus'], function (litmus) { >> new litmus.Test('example test', function () { >> this.ok(true, 'an assertion'); >> }).run(); >> }); >> >> Thoughts? >> >> Richard > > >
On 8 November 2011 22:45, Richard Hodgson <rightaboutnow@gmail.com> wrote: > I'd rather we avoid having a different structure between CJS and AMD > formats of the code, it means having to update dependency paths in > modules during the conversion between each format. > > Thinking about it...not everything has to be in a litmus/ dir, only > the modules we expect people to depend on. > Does this mean we assume that the AMD module loader (e.g. requirejs) will have paths configured for "modules we expect people to depend on" - i.e. ones we are exposing - and not for others? Tom Whilst Npm doesn't support a 'main' directory anymore, having a > convention for modules we consider public is probably a Good Thing. > > Richard. > > > On 3 November 2011 09:55, Tom Yandell <tom@yandell.me.uk> wrote: > > Ugh, is this the pattern? I guess I could get used to it :-s. I guess the > > less we modify the packages during the AMD conversion the better. > > > > Tom > > > > On 03/11/2011 09:32, Richard Hodgson wrote: > > > > I'm happy to optimise the API later, there is a risk it could become a > bit > > magic. > > Does this mean we move everything from lib/ to litmus/ ? > > Richard > > On 1 Nov 2011, at 21:57, Tom Yandell <tom@yandell.me.uk> wrote: > > > > Paths passed to Node's require must be as they appear in an NPM package, > > with the exception of the main module if you specify a "main" in your > > package.json: > > > http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders > > When running in node, the only user-facing parts are the litmus module > and > > the command line runner (i.e. the "litmus" command). The litmus module is > > used for specifying (i.e. exporting) tests and suites and the > command-line > > runner is used to run them. > > In the browser, I'd like tests to be specified in the same way (i.e. > > creating litmus.Test and litmus.Suite objects), but the way they are > loaded, > > executed and reported is necessarily different. > > I'm not against changing modules for the browser. In Spectrum, for > example, > > I think we'll have to statically inject a template loader that works in > the > > browser when we do the AMD conversion. OTOH, I'm not sure if there's a > case > > for it here. I think I like the following best because it's not too > magic: > > require(['litmus', 'litmus/browser'], function (litmus, browser) { > > browser.run(new litmus.Test('example test', function () { > > this.is(1 + 1, 2, '1 + 1 is 2'); > > }); > > }); > > It would be nice if the source for the litmus/browser module doesn't > have to > > live in litmus/browser.js in the source package (am I being picky?). I > wish > > the package.json contained a module root rather than a main module. > > I guess most people with any moderately sized project would have > something > > like: > > require(['litmus/browser', './my/test/suite'], function (browser, > suite) > > { > > browser.run(suite); > > }); > > Regards > > Tom > > On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com> > wrote: > >> > >> Hi, > >> > >> This is the current API for using Litmus in the browser (from the > >> https://github.com/usenode/litmus.js/tree/easy-clientside-install > >> branch): > >> > >> require(['browser', 'litmus'], function (browser, litmus) { > >> browser.run(new litmus.Test('example test', function () { > >> this.ok(true, 'an assertion'); > >> })); > >> }); > >> > >> This could be simpler. I'd prefer the browser dist to know which test > >> runner to use, like the command line. > >> > >> require(['litmus'], function (litmus) { > >> new litmus.Test('example test', function () { > >> this.ok(true, 'an assertion'); > >> }).run(); > >> }); > >> > >> Thoughts? > >> > >> Richard > > > > > > >
On 8 November 2011 23:11, Tom Yandell <tom@yandell.me.uk> wrote: > On 8 November 2011 22:45, Richard Hodgson <rightaboutnow@gmail.com> wrote: > >> I'd rather we avoid having a different structure between CJS and AMD >> formats of the code, it means having to update dependency paths in >> modules during the conversion between each format. >> >> Thinking about it...not everything has to be in a litmus/ dir, only >> the modules we expect people to depend on. >> > > Does this mean we assume that the AMD module loader (e.g. requirejs) will > have paths configured for "modules we expect people to depend on" - i.e. > ones we are exposing - and not for others? > I guess so. I don't mind that as a convention. After wrestling with an annoying RequireJS bug, I've got the above API working. https://github.com/usenode/litmus.js/compare/master...easy-clientside-install Run `make browser-dist` and have a look at the dist/ dir in the project root. I've created a simple example for now - https://github.com/usenode/litmus.js/blob/easy-clientside-install/dist-example.html. Its copied to the dist dir too, so you should be able to open it in your browser and see a passing test. Maybe in the future there will be an examples dir somewhere. Richard. > > Tom > > Whilst Npm doesn't support a 'main' directory anymore, having a >> convention for modules we consider public is probably a Good Thing. >> >> Richard. >> >> >> On 3 November 2011 09:55, Tom Yandell <tom@yandell.me.uk> wrote: >> > Ugh, is this the pattern? I guess I could get used to it :-s. I guess >> the >> > less we modify the packages during the AMD conversion the better. >> > >> > Tom >> > >> > On 03/11/2011 09:32, Richard Hodgson wrote: >> > >> > I'm happy to optimise the API later, there is a risk it could become a >> bit >> > magic. >> > Does this mean we move everything from lib/ to litmus/ ? >> > Richard >> > On 1 Nov 2011, at 21:57, Tom Yandell <tom@yandell.me.uk> wrote: >> > >> > Paths passed to Node's require must be as they appear in an NPM package, >> > with the exception of the main module if you specify a "main" in your >> > package.json: >> > >> http://nodejs.org/docs/v0.5.10/api/modules.html#loading_from_node_modules_Folders >> > When running in node, the only user-facing parts are the litmus module >> and >> > the command line runner (i.e. the "litmus" command). The litmus module >> is >> > used for specifying (i.e. exporting) tests and suites and the >> command-line >> > runner is used to run them. >> > In the browser, I'd like tests to be specified in the same way (i.e. >> > creating litmus.Test and litmus.Suite objects), but the way they are >> loaded, >> > executed and reported is necessarily different. >> > I'm not against changing modules for the browser. In Spectrum, for >> example, >> > I think we'll have to statically inject a template loader that works in >> the >> > browser when we do the AMD conversion. OTOH, I'm not sure if there's a >> case >> > for it here. I think I like the following best because it's not too >> magic: >> > require(['litmus', 'litmus/browser'], function (litmus, browser) { >> > browser.run(new litmus.Test('example test', function () { >> > this.is(1 + 1, 2, '1 + 1 is 2'); >> > }); >> > }); >> > It would be nice if the source for the litmus/browser module doesn't >> have to >> > live in litmus/browser.js in the source package (am I being picky?). I >> wish >> > the package.json contained a module root rather than a main module. >> > I guess most people with any moderately sized project would have >> something >> > like: >> > require(['litmus/browser', './my/test/suite'], function (browser, >> suite) >> > { >> > browser.run(suite); >> > }); >> > Regards >> > Tom >> > On 31 October 2011 23:54, Richard Hodgson <rightaboutnow@gmail.com> >> wrote: >> >> >> >> Hi, >> >> >> >> This is the current API for using Litmus in the browser (from the >> >> https://github.com/usenode/litmus.js/tree/easy-clientside-install >> >> branch): >> >> >> >> require(['browser', 'litmus'], function (browser, litmus) { >> >> browser.run(new litmus.Test('example test', function () { >> >> this.ok(true, 'an assertion'); >> >> })); >> >> }); >> >> >> >> This could be simpler. I'd prefer the browser dist to know which test >> >> runner to use, like the command line. >> >> >> >> require(['litmus'], function (litmus) { >> >> new litmus.Test('example test', function () { >> >> this.ok(true, 'an assertion'); >> >> }).run(); >> >> }); >> >> >> >> Thoughts? >> >> >> >> Richard >> > >> > >> > >> > >