Keystone.js Framework Tips (2)

keystonejs

1. Test in keystone.js

I use Mocha as test runner to tell what passes and fails, and Chai for assertion or should libraries to run specific tests.

https://groups.google.com/forum/?nomobile=true#!topic/keystonejs/AvpvUpHNTn0

http://stackoverflow.com/questions/22231078/how-do-i-unit-test-keystonejs-models
https://gist.github.com/rtgibbons/e18d8066680a0350fe41

https://github.com/webteckie/keystonejs-stub

process.env.NODE_ENV = process.env.NODE_ENV || 'test';
require('dotenv').load();

var keystone = require('keystone');
var chai = require('chai');
var dbURI = process.env.MONGO_URL

keystone.init({
  'name': 'Post Model Test',
  's3 config': {} //has to be set, but isn't used in our models
});

var Post = null;

keystone.import('../../models');

chai.should();

describe('Posts', function() {
  beforeEach(function(done){
    if (keystone.mongoose.connection.db) return done();
    console.log('Connecting to ' + dbURI)
    keystone.mongoose.connect(dbURI, done);
  });

  it('should be a connection to Mongo', function(done){
    keystone.mongoose.connection.db.should.be.a('Object');
    done();
  });

  it('should be a Mongoose Model', function(done) {
    Post = keystone.list('Post');

    Post.should.be.a('Object');
    Post.should.have.property('model').be.a('Function');
    Post.should.have.property('schema').be.a('Object');

    done();
  });
});

2. create a gap between tr (table rows)

table {
    border-collapse: separate;
    border-spacing: 0 15px;
}

http://stackoverflow.com/questions/1264187/css-how-do-i-create-a-gap-between-rows-in-a-table

http://stackoverflow.com/questions/10690299/how-to-add-a-margin-to-a-table-row-tr

3.Keystone JS CMS Deployment error: cannot find module ‘../build/release/bson’ code ‘module_not_found’

http://stackoverflow.com/questions/28651028/cannot-find-module-build-release-bson-code-module-not-found-js-bson

Solution:

root@keystonejs:~# npm install -g npm-check-updates

debian@keystonejs:~/myproject/manalcjim$ npm-check-updates -u

debian@keystonejs:~/myproject/manalcjim$ npm install

Donate $5 to me for a coffee with PayPal and read more professional and interesting technical blog articles. Feel free to visit my web app, WhizWallet, to apply for credit, store or gift cards, DealsPlus to browse daily deals and store coupons to save money.
Follow me @Yaoli0615 at Twitter to get latest tech updates.

Resource:

A Smarter Way to Learn JavaScript. The new tech-assisted approach that requires half the effort

Secrets of the JavaScript Ninja

Node.js Design Patterns

Web Development with MongoDB and NodeJS

Node.js the Right Way: Practical, Server-Side JavaScript That Scales

Web Development with Node and Express: Leveraging the JavaScript Stack

Learn NodeJS in 1 Day: Complete Node JS Guide with Examples

Learning Node: Moving to the Server-Side

Getting MEAN with Mongo, Express, Angular, and Node

Advertisements

About liyao13

Yao Li is a web and iOS developer, blogger and he has a passion for technology and business. In his blogs, he shares code snippets, tutorials, resources and notes to help people develop their skills. Donate $5 to him for a coffee with PayPal at About Me page and read more professional and interesting technical blog articles. Follow him @Yaoli0615 at Twitter to get latest tech updates.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s