Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of a good bug report for NeDB
// Put all your require statements at the top. Your gist should contain a package.json which lets me download all
// the dependencies needed to test your bug report with a simple 'npm install'
var async = require('async')
, someOtherModule = require('xxx')
, fs = require('fs');
// Then require nedb and chai. You need to use chai for your assertions
var Nedb = require('nedb')
, chai = require('chai')
, assert = chai.assert; // Chai supports assert and should style of assertion
chai.should(); // Check out the doc, use is straightforward http://chaijs.com/
// If your test includes persistence, make sure to put file name in a variable and erase its contents to avoid hysteresis
var filename = 'bugreport.db';
fs.writeFileSync(filename, '', 'utf8');
// Then write actual test code, with assertions to show the expected behavior
var db = new Nedb({ autoload: true, filename: filename });
db.insert({ some: 'document' });
db.find({}, function (err, res) {
res.length.should.equal(1); // Assertion should of course throw if there is a problem
});
{
"dependencies": {
"nedb": "1.2.0",
"chai": "3.2.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment