Last active
July 27, 2017 18:09
-
-
Save thomasmichaelwallace/ac0bf807646fac0758dbf004e0309456 to your computer and use it in GitHub Desktop.
A simple snippet for a time based test.
This file contains hidden or 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
describe('My awesome new way of doing things', () => { | |
it('should be performant.' () => { | |
const maxRunTimeMs = 500; | |
const start = process.hrtime(); | |
return doSomethingAwesome() | |
.then(() => { | |
const runtime = process.hrtime(start); | |
const runtimeNs = (runtime[0] * 1e9) + runtime[1]; | |
const runtimeMs = runtimeNs / 1e6; | |
expect(runtimeMs).to.be.lessThan(maxRunTimeMs); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment