Permalink
Browse files

Execute all tests through the terminal. No more client-test-runner.ht…

…ml for clientside tests.
  • Loading branch information...
1 parent cbe17e5 commit 4fde145b83a36d9d25addebe49f818d23cd07ad8 @NilsLattek committed Jul 10, 2012
View
@@ -1,5 +1,5 @@
# thanks to TJ: https://github.com/visionmedia/mocha/issues/106#issuecomment-2979500
-TESTS = $(shell find test/server test/shared -name "*.test.js")
+TESTS = $(shell find test/server test/shared test/client -name "*.test.js")
test:
@./node_modules/.bin/mocha $(TESTS)
View
@@ -5,7 +5,7 @@ This example shows how to reuse code between the client and server. A typical us
Feel free to use it as a basic template for your applications.
##Project structure
-This backbone application is divided into a couple of AMD modules. A special shared module is used inside the node.js server.
+This backbone application is divided into a couple of AMD modules. A special shared module is used inside the node.js server.
It is possible to test all modules using mocha and expect.js. (Examples included)
The Backbone app is inside the 'client' folder.
@@ -25,7 +25,7 @@ Check out this git repository:
$ git clone git@github.com:NilsLattek/backbone-requirejs-node-boilerplate.git
Remove git history if you want to use this example as a template for your project:
-
+
$ cd backbone-requirejs-node-boilerplate
$ rm -rf .git
@@ -48,16 +48,12 @@ Or use nodemon for watching your server files and automatically restart the serv
$ npm install -g nodemon
$ nodemon server/server.js
-Run serverside and shared modules unittests:
+Run unittests:
$ make test
-Run clientside unittests:
-
- Open 'client-test-runner.html' in your browser. (TODO: it would be nice to run these along with the serverside tests in one command.) If you add more tests you have to adjust the client-test-runner.html file and list the new test files. This is not the optimal way and should be optimized...
-
Build (concatenate and minify) everything using r.js:
-
+
$ cd bin
$ ./build.sh
@@ -68,7 +64,6 @@ Start production environment (node will use the client-build folder with the min
###Roadmap
-- Use r.js to optimize CSS files
- Provide a coffeescript version
- Add strict mode: "use strict";
View
@@ -28,7 +28,7 @@ text!templates/entries-list.handlebars
text!templates/entry-item.handlebars
js/views/entry-item.js
js/views/entries-list.js
-js/entry-validation.js
+js/models/../../../shared/js/entry_validation.js
js/models/entry.js
js/collections/entries.js
js/routers/workspace.js
Oops, something went wrong.
@@ -1,61 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <link rel="stylesheet" href="test/client/libs/mocha.css"/>
- <script type="text/javascript" src="client/js/libs/require/require.js"></script>
- <script type="text/javascript" src="client/js/libs/underscore.js"></script>
-
- <script type="text/javascript">
-
- var specs = [
- 'models/entry.test'
- // add additional tests
- ];
-
- require.config(
- {
- shim: {
- 'zepto': {
- exports: 'Zepto'
- },
- 'underscore': {
- exports: '_'
- },
- 'backbone': {
- //These script dependencies should be loaded before loading
- //backbone.js
- deps: ['underscore', 'zepto'],
- //Once loaded, use the global 'Backbone' as the
- //module value.
- exports: 'Backbone'
- },
- 'handlebars': {
- exports: 'Handlebars'
- }
- },
- baseUrl:'test/client/',
- paths:{
- 'zepto':'../../client/js/libs/zepto'
- , 'underscore': '../../client/js/libs/underscore'
- , 'backbone': '../../client/js/libs/backbone'
- , 'text': '../../client/js/libs/require/text'
- , 'handlebars': '../../client/js/libs/handlebars'
- // list shared dependencies, else they won't be resolved successfully
- , 'entry-validation': '../../shared/js/entry-validation'
- }
- }
- );
-
- require(['require', 'libs/expect', 'libs/mocha'], function(require){
- mocha.setup('bdd');
-
- require(specs, function(module){
- mocha.run();
- });
- });
- </script>
-</head>
-<body>
- <div id="mocha"></div>
-</body>
-</html>
View
@@ -15,7 +15,6 @@
, 'backbone': 'libs/backbone'
, 'text': 'libs/require/text'
, 'handlebars': 'libs/handlebars'
-
},
modules: [
{
@@ -1,13 +1,13 @@
define([
'zepto'
, 'backbone'
- , 'entry-validation'
+ , '../../../shared/js/entry_validation'
], function(
$
, Backbone
, entryValidation
) {
-
+
var Entry = Backbone.Model.extend({
validate: function(attrs) {
View
@@ -1,13 +1,15 @@
{
"name": "timesheet"
, "version": "0.0.1"
- , "dependencies": {
+ , "dependencies": {
"express": "~2.5.6"
, "eco": "1.1.0-rc-3"
, "amdefine": ">=0.0.2"
}
, "devDependencies": {
"mocha": "0.10.0"
, "expect.js": "0.1.2"
+ , "requirejs": "2.0.4"
+ , "jsdom": "0.2.14"
}
}
@@ -1,5 +1,5 @@
// validation logic is shared between client and server
-var entryValidation = require('../../shared/js/entry-validation');
+var entryValidation = require('../../shared/js/entry_validation');
// just for demonstration, normally you would store everything in a database
var entries = [
View
@@ -16,7 +16,8 @@ app.configure(function(){
app.configure('development', function(){
app.use(express.static(path.join(application_root, '../client')));
- app.use(express.static(path.join(application_root, '../shared')));
+ // used to load shared modules on the fly during development
+ app.use(express.static(path.join(application_root, '../')));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
@@ -2,9 +2,8 @@
if (typeof define !== 'function') { var define = require('amdefine')(module); }
/* require additional modules if needed
-define('entry-validation', ['./other-module.js'], function (other-module) {*/
-define('entry-validation', [], function () {
-
+define(['./other-module.js'], function (other-module) {*/
+define([], function () {
return {
validate: function(attrs) {
if (!attrs.name) {
Oops, something went wrong.

0 comments on commit 4fde145

Please sign in to comment.