TDD
키워드
TDD란
Jest
Describe-Context-It 패턴
단위테스트란TDD(Test Driven Development)

TDD Cycle
Jest
BDD(Behavior Driven Development)
Give When Then
Last updated
키워드
TDD란
Jest
Describe-Context-It 패턴
단위테스트란
Last updated
App.test.ts
App.spec.tstest('add', () => {
expect(add(1,2)).toBe(3)
})module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
],
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest', {
jsc: {
parser: {
syntax: 'typescript',
jsx: true,
decorators: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
}],
},
};npx jest --watchAll# Given
# 필요한 것
stove = Stove.new(700.watts)
# When
# 수행 동작
food = stove.cook(3.minute)
# Then
# 예상 결과
assert food.complete?const context = describe;
decribe('add', () => {
context('with two arguments', () => {
it('returns sum of two numbers', () => {
expect(add(1,2)).toBe(3)
})
})
})