KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

테스트

API 테스트하기

@api(/api/notes)는 서버를 시작하지 않고 프로젝트 자체의 라우트에 요청을 보냅니다(자체 API 호출하기 참고). 그래서 테스트에서 클라이언트가 받게 될 응답을 확인할 수 있습니다:

<import package="KScript.Net" />

<test name="a note is saved">
  <let name="added" value="@api(/api/notes, post: { title: 'Ship it' })" />
  <expect value="$added.status" equals="201" />
  <expect value="@api(/api/notes/$added->convert(from: json).id)->convert(from: json).title" equals="'Ship it'" />
</test>
import KScript.Net

test(name: 'a note is saved') {
  $added = @api(/api/notes, post: { title: 'Ship it' })
  expect($added.status, equals: 201)
  expect(@api(/api/notes/$added->convert(from: json).id)->convert(from: json).title, equals: 'Ship it')
}