Testing
not in the production, just for element checking before a deployment
Automated Tests
반복되는 test 작업을 줄임
Unit
receives a single case input, return certain type of output
wouldn’t pass unless the entire process works out
e.g. validation email & password -> similar word -> set the function as a unit with diff. inputIntegration
multiple single inputs -> integrates into a single output
e.g. email / pw -> basic email : passwordE2E
end-to-end
user-perspective, operation on the browser, entire process without manually fixing it
hard to point where the error comes out
TDD
Test Driven Development
fail-fix-refactor
- one test at a time
BDD
Bahaviour Driven Development
E2E
- testing single unit, element to test entirely
- implemented in non-technical env. -> no coding
diff: technical or not
Testing Frameworks: the function to run the tests (in JS - Mocha, Jasmine(React), Jest)
# : e.g. #func() : recall all the elements including func()
- describe()
- it()
- Hooks; rather than list singly, wrap it for organizing
- start a server, create DB
1 | describe('hooks', function() { |
inside each hooks: it()
Assertion
assert -> technical, not readable
- built-in in Node.js
- typeOf(var, typeof, [msg])
- equal(var, val, [msg])
- lengthOf(var, length, [msg])
expect
e.g. expect(foo).to.not.equal('bar')
should
e.g. foo.should.not.equal('bar')
1 | function add (a, b) { |
REF
kent c.dodds web
mochajs.com