Skip to content

Instantly share code, notes, and snippets.

@RubenVerborgh
Last active December 10, 2015 21:18
Show Gist options
  • Save RubenVerborgh/4494356 to your computer and use it in GitHub Desktop.
Save RubenVerborgh/4494356 to your computer and use it in GitHub Desktop.
Chais as Promised performance issues
#!/usr/bin/env mocha --reporter spec --timeout 5000
var chai = require("chai");
var Q = require("q");
chai.should();
chai.use(require("chai-as-promised"));
describe("The string", function() {
it("should eventually be string", function() {
'x'.should.be.a('string');
});
it("should eventually be string", function() {
for(var i = 0; i < 200; i++)
'x'.should.be.a('string');
});
});
describe("The promise", function() {
it("should eventually be string", function(done) {
Q.delay('x', 10).should.eventually.be.a('string').notify(done);
});
it("should eventually be string", function(done) {
var callbackCount = 0;
for(var i = 0; i < 200; i++)
Q.delay('x', 10).should.eventually.be.a('string').notify(function () {
if (++callbackCount == 200)
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment