> On Mar 29, 2015, at 8:43 AM, Secretmapper <[email protected]> wrote: > > I'm on the way of creating my first very own javascript library (a small > client side library, say a stereotypical jquery library (but standalone) like > tooltips) > > However, I'm curios us to how developers normally create like this (and how > it's tested). > > For example, how can I create the library and be able to test it out easily? > Should I act it out as a generic webapp (with gulp and tasks like > livereload?) and then just copy paste the relevant files when isolating the > library?
I'd generally go "as small as possible".
If you're doing DOM things, that means you're going to need to test against a
DOM implementation -- a browser, even headless, like phantom, or a non-browser
DOM like JSDOM. I'd generally make a package (especially to publish on the npm
registry) like so:
package.json
{
"name": "mylibrary",
....
"main": "mylibrary.js",
"devDependencies": {
"jsdom": "^1",
"tape": "^2"
}
"scripts": { "test": "tape test.js" }
}
mylibrary.js
do things with the DOM
test.js
var dom = require('jsdom');
var test = require('tape');
...
set up dom here, loading your mylibrary.js into it -- maybe you can require it,
if you've made a commonjs library, maybe you have to tell jsdom to load it like
a script, or load and eval it yourself
test('test my library', function (t) {
t.ok(dom.stuff.mylibrary.whatever);
t.end();
})
Super minimal. I only add build tools when needed, and if libraries are small,
you don't need very much.
Aria
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/D7BDD379-81EE-4511-8B1E-75612214506C%40dinhe.net.
For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME cryptographic signature
