Skip to Content
한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
book

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

by 한선용, 이선 브라운
May 2021
Beginner to intermediate
448 pages
9h 47m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
437
부록
G
REST API와 JSON
G.1
익스프레스를 통한
API
제공
이 상태로 테스트를 시작하면 모두 실패합니다. 하나씩 살펴봅시다.
/
api
/
vacations
테스트 항목에는
vacation0
.
price
의 타입이
number
라는 어서션이 있습니다. 하지만 부록
E
에서 수정했듯
vacation
에는
price
프로퍼티가 없고
_
doc
.
priceInCents
가 있습니다. 그
런데 테스트 항목에서
vacation0
를 콘솔에 출력해보면
_
doc
없고
priceInCents
가 프로
퍼티로 발견됩니다. 역자는 몽고
DB
나 몽구스에 대한 지식이 부족해 이 현상의 원인은 파악할
수 없었습니다.
이에 따라 테스트 함수를 다음과 같이 변경했고 몽고
DB
PostgreSQL
에서 모두 성공한 것
을 확인했습니다.
test(‘GET /api/vacations’, async () => {
const vacations = await _fetch(‘get’, ‘/api/vacations’)
expect(vacations.length).not.toBe(0)
const vacation0 = vacations[0]
expect(vacation0.name).toMatch(/\w/)
expect(typeof (vacation0.priceInCents || vacation0.price)).toBe(‘number’) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한성용, 이선 브라운

Publisher Resources

ISBN: 9791162244227