Last active
June 21, 2021 00:51
-
-
Save lmiller1990/8e17919503f119d656e96f55fccc4bc5 to your computer and use it in GitHub Desktop.
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
const describe = (desc, fn) => { | |
console.log(desc) | |
fn() | |
} | |
const it = (msg, fn) => describe(' ' + msg, fn) | |
const matchers = (exp) => ({ | |
toBe: (asssertion) => { | |
if (exp === assertion) { | |
console.log('pass') | |
return true | |
} else { | |
console.log('fail') | |
return false | |
} | |
} | |
}) | |
const expect = (exp) => matchers(exp) | |
function adder(a, b) { | |
return a + b | |
} | |
describe('adder', () => { | |
it('adds two numbers', () => { | |
const result = adder(1, 2) | |
expect(result).toBe(3) | |
}) | |
}) | |
module.exports = { | |
describe, | |
expect, | |
it, | |
matchers | |
} |
asssertion ?
was this testing framework ever executed?
@SumitBando you can just put this in a JS file and run it with Node.js.
If you'd like to learn to build a testing framework with more features, check out this playlist I made.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Amazing start for a wonderful test framework