Created
February 27, 2022 23:12
-
-
Save malkab/d2b3e8e6e4339bca2b3a774d86f43807 to your computer and use it in GitHub Desktop.
Testing TypeScript with Mocha
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
/** | |
This describe blocks will be executed sequentially | |
A very important thing to keep in mind when testing with Mocha is, as always, | |
the async nature of JavaScript. Everything inside a describe/it Mocha block | |
will be executed synchroneously, but the results of everything outside them | |
is not guaranteed to be executed sequentially with the rest of the **it** | |
blocks. Therefore, everything should be inside an "it" block if possible. | |
*/ | |
describe("Enter SystemPerformance Dataset", function() { | |
it("Enter SystemPerformance Dataset", () => { | |
const data: any = { | |
ThLossSy: 1.04, | |
TEffNom: 43.5, | |
SteamGP: 91.5 | |
} | |
expect(analysis.validate(data), | |
"Validation of SystemPerformance Dataset").to.be.null; | |
analysis.setData(data).updateDatasetStatus().updateStatus(); | |
expect(analysis.inputDatasetStatus, | |
"Input Dataset status for SystemPerformance") | |
.to.be.deep.equal(datasetStatusSystemPerformance); | |
expect(analysis.status, "Checking status").to.equal(EROSTATUS.READY); | |
}) | |
}) | |
console.log("THIS IS NOT SAFE, WILL EXECUTE ASYNC WHEN COMPARED WITH THE describe/it MOCHA BLOCKS"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment