Skip to content

Instantly share code, notes, and snippets.

@wicksome
Created September 14, 2018 10:02
Show Gist options
  • Save wicksome/3e1a97e2b16a2abfae68b6202937f3e6 to your computer and use it in GitHub Desktop.
Save wicksome/3e1a97e2b16a2abfae68b6202937f3e6 to your computer and use it in GitHub Desktop.
Simple Test Case Code
const TEST = {};
function assertEquals(expected, actual) {
if (expected !== actual)
throw new Error(
`Not equals.\nExpected :${expected}[39m\nActual :${actual}`
);
}
function RunAllTest() {
Object.getOwnPropertyNames(TEST)
.filter(name => typeof TEST[name] === "function")
.filter(name => name !== "TestCaseExample")
.forEach(testCase => {
console.log(`## TEST: ${testCase}`);
TEST[testCase].call();
console.log();
});
}
//////////////////////////////////////////////////////////////////
// TEST CODES
TEST.test1 = () => {
// given
// when
// then
assertEquals("1", "1")
};
RunAllTest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment