Skip to content

Instantly share code, notes, and snippets.

@cwchentw
Created May 9, 2015 08:09
Show Gist options
  • Save cwchentw/fbb0c9d7754697daafdd to your computer and use it in GitHub Desktop.
Save cwchentw/fbb0c9d7754697daafdd to your computer and use it in GitHub Desktop.
mocha didn't work when using with fs.writeFile or fs.readFile
var fs = require('fs'),
os = require('os');
var assert = require('assert'),
expect = require('expect.js'),
should = require('should');
describe('Test on I/O', function() {
it('write test', function() {
fs.writeFile('./text.txt', "Hello Node.js" + os.EOL, function(err) {
if (err) {
throw "Unable to read file";
}
expect(3).to.equal(4); // expect didn't work
assert.equal(3, 4); // assert didn't work
(3).should.be.exactly(4); // should didn't work
});
});
it('read test', function() {
fs.readFile('./file.txt', function(err, data) {
if (err) {
throw "Unable to read file";
}
expect(3).to.equal(4); // expect didn't work
assert.equal(3, 4); // assert didn't work
(3).should.be.exactly(4); // should didn't work
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment