Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@balupton /README.md
Last active Sep 27, 2015

JQTest: Server-Side jQuery testing with Node.js, Expresso and CoffeeScript. Test faster, test funner.

JQTest

Server-Side jQuery testing with Node.js, Expresso and CoffeeScript. Test faster, test funner.

# Server-Side jQuery testing with Node.js
# Copyright 2011 Benjamin Lupton
# MIT Licensed
# https://gist.github.com/1191942
# -------------------------------------
# Requires
fs = require('fs')
assert = require('assert')
jquery = require('jquery')
cwd = process.cwd();
# -------------------------------------
# Helpers
appendScript = (scriptPath) ->
scriptPath = "#{cwd}/#{scriptPath}";
scriptContents = fs.readFileSync(scriptPath).toString()
return this.append "<script>#{scriptContents}</script>"
createjQuery = ->
$ = jquery.create();
$.fn.appendScript = appendScript
return $
createjQueryWith = (scripts,html) ->
$ = createjQuery();
$body = $('body')
scripts = [scripts] unless scripts instanceof Array
$body.appendScript script for script in scripts
$body.append html if html
return $
# -------------------------------------
# Export
module.exports = {
fs,assert,jquery
appendScript
createjQuery
createjQueryWith
}
@balupton
Owner
balupton commented Sep 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.