Created
May 9, 2015 08:09
-
-
Save cwchentw/fbb0c9d7754697daafdd to your computer and use it in GitHub Desktop.
mocha didn't work when using with fs.writeFile or fs.readFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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