{"id":24674,"date":"2026-07-15T11:06:08","date_gmt":"2026-07-15T02:06:08","guid":{"rendered":"https:\/\/www.ecomottblog.com\/?p=24674"},"modified":"2026-07-15T12:54:48","modified_gmt":"2026-07-15T03:54:48","slug":"vitest%e3%81%a8supertest%e3%81%ab%e3%82%88%e3%82%8bexpress-api%e3%83%86%e3%82%b9%e3%83%88%e3%81%ae%e5%ae%9f%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/www.ecomottblog.com\/?p=24674","title":{"rendered":"Vitest\u3068Supertest\u306b\u3088\u308bExpress API\u30c6\u30b9\u30c8\u306e\u5b9f\u8df5"},"content":{"rendered":"<p>\u307f\u306a\u3055\u3093\u3001\u3053\u3093\u306b\u3061\u306f\uff01\u30af\u30e9\u30a6\u30c9\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u90e8\u306e\u5bfa\u8c37\u3067\u3059\u3002<br \/>\n7\u6708\u306b\u5165\u308a\u3001\u5317\u6d77\u9053\u3082\u3044\u3088\u3044\u3088\u590f\u672c\u756a\u3068\u3044\u3046\u6c17\u6e29\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u306d\u3002\u6691\u3044\u65e5\u306b\u98f2\u3080\u51b7\u305f\u3044\u70ad\u9178\u6c34\u306f\u6700\u9ad8\u3067\u3059\u304c\u3001\u304a\u8179\u3092\u58ca\u3055\u306a\u3044\u3088\u3046\u306b\u4f53\u8abf\u7ba1\u7406\u306b\u306f\u6c17\u3092\u3064\u3051\u3066\u3044\u304d\u307e\u3059\uff01<\/p>\n<p>Vitest\u3068\u3044\u3046\u3068\u3001Vite\u3084React\u3068\u4e00\u7dd2\u306b\u4f7f\u3046\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5411\u3051\u306e\u5370\u8c61\u304c\u5f37\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3067\u3059\u304c\u3001\u4eca\u56de\u89e6\u3063\u3066\u307f\u3066\u300c\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306eAPI\u30c6\u30b9\u30c8\u3067\u3082\u304b\u306a\u308a\u4f7f\u3044\u3084\u3059\u3044\u300d\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9API\u3092\u4f8b\u306b\u3001Vitest\u3068Supertest\u3092\u4f7f\u3063\u3066Express API\u306e\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u305f\u8a71\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n\u4eca\u56de\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u306e\u69cb\u6210\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30d0\u30c3\u30af\u30a8\u30f3\u30c9: Express + TypeScript<\/li>\n<li>\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9: React + TypeScript<\/li>\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9: PostgreSQL<\/li>\n<li>\u5b9f\u884c\u74b0\u5883: Podman Compose<\/li>\n<li>\u30c6\u30b9\u30c8: Vitest + Supertest<\/li>\n<\/ul>\n<h2>1. Vitest\u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3067\u4f7f\u3063\u3066\u307f\u305f\u7406\u7531<\/h2>\n<p>\u3082\u3068\u3082\u3068Vitest\u306f\u3001Vite\u30d9\u30fc\u30b9\u306e\u9ad8\u901f\u306a\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<br \/>\n<code>describe<\/code>\u3001<code>it<\/code>\u3001<code>expect<\/code> \u306a\u3069\u3001Jest\u306b\u8fd1\u3044\u66f8\u304d\u65b9\u304c\u3067\u304d\u308b\u305f\u3081\u3001Jest\u3092\u4f7f\u3063\u305f\u3053\u3068\u304c\u3042\u308b\u4eba\u306a\u3089\u304b\u306a\u308a\u5165\u308a\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3067\u4f7f\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3063\u305f\u7406\u7531\u306f\u3001\u4e3b\u306b\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<ul>\n<li>TypeScript\u3067\u305d\u306e\u307e\u307e\u30c6\u30b9\u30c8\u3092\u66f8\u304d\u305f\u3044<\/li>\n<li>Express API\u3092Supertest\u3067\u78ba\u8a8d\u3057\u305f\u3044<\/li>\n<li>\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3092\u8efd\u304f\u3057\u305f\u3044<\/li>\n<li>\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u4ee5\u5916\u3067\u3082Vitest\u304c\u4f7f\u3048\u308b\u304b\u8a66\u3057\u305f\u3044<\/li>\n<\/ul>\n<p>\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u307f\u308b\u3068\u3001\u8a2d\u5b9a\u3082\u30b7\u30f3\u30d7\u30eb\u3067\u3001Express API\u306e\u30c6\u30b9\u30c8\u306b\u3082\u81ea\u7136\u306b\u4f7f\u3048\u307e\u3057\u305f\u3002<\/p>\n<h2>2. Vitest\u306e\u5c0e\u5165\u65b9\u6cd5\u3068\u8a2d\u5b9a<\/h2>\n<h3>2-1. Vitest\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u300c\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306bVitest\u3092\u5165\u308c\u308b\u306e\u3063\u3066\u9762\u5012\u305d\u3046\u2026\u300d\u3068\u601d\u308f\u308c\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u624b\u9806\u306f\u9a5a\u304f\u307b\u3069\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre><code class=\"bash\">npm install -D vitest supertest @types\/supertest\n<\/code><\/pre>\n<ul>\n<li>vitest: \u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3001\u7d50\u679c\u3092\u691c\u8a3c\u30fb\u96c6\u8a08\u3059\u308b\u305f\u3081\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/li>\n<li>supertest &amp; @types\/supertest: Express\u30a2\u30d7\u30ea\u3092\u64ec\u4f3c\u7684\u306b\u53e9\u304f\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<\/ul>\n<h3>2-2. \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb (vitest.config.ts) \u306e\u4f5c\u6210<\/h3>\n<p>\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u914d\u4e0b\u306b <code>vitest.config.ts<\/code> \u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"typescript\">import { defineConfig } from \"vitest\/config\";\n\nexport default defineConfig({\n  test: {\n    environment: \"node\",\n    coverage: {\n      reporter: [\"text\", \"html\"],\n    },\n  },\n});\n<\/code><\/pre>\n<p>\u30dd\u30a4\u30f3\u30c8\u306f <code>environment: \"node\"<\/code> \u306e\u6307\u5b9a\u3067\u3059\u3002Express API\u306e\u30c6\u30b9\u30c8\u306a\u306e\u3067\u3001\u30d6\u30e9\u30a6\u30b6\u74b0\u5883\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3059\u308b <code>jsdom<\/code> \u3067\u306f\u306a\u304f\u3001Node.js\u74b0\u5883\u3067\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>2-3. package.json \u3078\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u8ffd\u52a0<\/h3>\n<p>\u30c6\u30b9\u30c8\u3092\u7c21\u5358\u306b\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u3001scripts \u306b\u30b3\u30de\u30f3\u30c9\u3092\u767b\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"json\">{\n  \"scripts\": {\n    \"type-check\": \"tsc --noEmit\",\n    \"test\": \"vitest run\",\n    \"test:watch\": \"vitest\"\n  }\n}\n<\/code><\/pre>\n<ul>\n<li><code>type-check<\/code>: TypeScript\u306e\u578b\u30c1\u30a7\u30c3\u30af\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n<li><code>test<\/code>: \u30c6\u30b9\u30c8\u3092\u4e00\u767a\u5b9f\u884c\u3057\u3066\u7d42\u4e86\u3057\u307e\u3059\uff08CI\u74b0\u5883\u306a\u3069\u306b\u4fbf\u5229\uff09\u3002<\/li>\n<li><code>test:watch<\/code>: \u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u3092\u76e3\u8996\u3057\u3001\u4fee\u6b63\u3059\u308b\u305f\u3073\u306b\u81ea\u52d5\u3067\u30c6\u30b9\u30c8\u3092\u518d\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<h2>3. \u30c6\u30b9\u30c8\u5bfe\u8c61\u306eAPI<\/h2>\n<p>\u4eca\u56de\u4f5c\u6210\u3057\u305f\u306e\u306f\u3001\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3092\u7ba1\u7406\u3059\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u30ab\u30ec\u30f3\u30c0\u30fcAPI\u3067\u3059\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-1024x683.png\" alt=\"\" width=\"1024\" height=\"683\" class=\"alignnone size-large wp-image-24678\" srcset=\"https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-1024x683.png 1024w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-300x200.png 300w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-768x512.png 768w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-1536x1024.png 1536w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-304x203.png 304w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea-282x188.png 282w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30ab\u30ec\u30f3\u30c0\u30fc\u30a2\u30d7\u30ea.png 1962w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<ul>\n<li><code>GET \/api\/health<\/code>: API\u304c\u6b63\u5e38\u306b\u8d77\u52d5\u3057\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/li>\n<li><code>GET \/api\/events<\/code>: \u767b\u9332\u3055\u308c\u3066\u3044\u308b\u4e88\u5b9a\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li><code>GET \/api\/events\/:id<\/code>: \u6307\u5b9a\u3057\u305fID\u306e\u4e88\u5b9a\u8a73\u7d30\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li><code>POST \/api\/events<\/code>: \u65b0\u3057\u3044\u4e88\u5b9a\u3092\u767b\u9332\u3059\u308b<\/li>\n<li><code>PUT \/api\/events\/:id<\/code>: \u6307\u5b9a\u3057\u305fID\u306e\u4e88\u5b9a\u3092\u66f4\u65b0\u3059\u308b<\/li>\n<li><code>DELETE \/api\/events\/:id<\/code>: \u6307\u5b9a\u3057\u305fID\u306e\u4e88\u5b9a\u3092\u524a\u9664\u3059\u308b<\/li>\n<\/ul>\n<p>\u30c6\u30b9\u30c8\u3067\u306f\u3001\u6b63\u5e38\u7cfb\u3060\u3051\u3067\u306a\u304f\u7570\u5e38\u7cfb\u3082\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5185\u5bb9\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u4e88\u5b9a\u4e00\u89a7\u304c\u65e5\u4ed8\u3001\u6642\u523b\u3001ID\u9806\u3067\u8fd4\u308b\u3053\u3068<\/li>\n<li>\u5b58\u5728\u3057\u306a\u3044ID\u3067\u306f404\u306b\u306a\u308b\u3053\u3068<\/li>\n<li>\u6709\u52b9\u306a\u4e88\u5b9a\u60c5\u5831\u306a\u3089\u4f5c\u6210\u3067\u304d\u308b\u3053\u3068<\/li>\n<li>\u5fc5\u9808\u9805\u76ee\u3084\u5f62\u5f0f\u304c\u4e0d\u6b63\u306a\u3089400\u306b\u306a\u308b\u3053\u3068<\/li>\n<li>\u66f4\u65b0\u3084\u524a\u9664\u304c\u3067\u304d\u308b\u3053\u3068<\/li>\n<li>\u524a\u9664\u5f8c\u306f\u540c\u3058ID\u3067\u53d6\u5f97\u3067\u304d\u306a\u3044\u3053\u3068<\/li>\n<\/ul>\n<p>API\u306f\u300c\u6b63\u5e38\u306b\u52d5\u304f\u3053\u3068\u300d\u3060\u3051\u3067\u306a\u304f\u3001\u300c\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u305f\u3068\u304d\u306b\u3069\u3046\u8fd4\u3059\u304b\u300d\u3082\u540c\u3058\u304f\u3089\u3044\u91cd\u8981\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3084\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3068\u9023\u643a\u3059\u308b\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u304a\u3044\u3066\u3001\u30a8\u30e9\u30fc\u6642\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3084\u30ec\u30b9\u30dd\u30f3\u30b9\u5f62\u5f0f\u304c\u7dba\u9e97\u306b\u5171\u901a\u5316\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306f\u3001\u547c\u3073\u51fa\u3057\u5074\u306e\u5b9f\u88c5\u30b3\u30b9\u30c8\u3092\u6e1b\u3089\u3059\u3053\u3068\u306b\u3082\u3064\u306a\u304c\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>4. DB\u306b\u4f9d\u5b58\u3057\u306a\u3044\u30c6\u30b9\u30c8\u306b\u3057\u305f<\/h2>\n<p>\u4eca\u56de\u306e\u30c6\u30b9\u30c8\u3067\u306f\u3001\u5b9f\u969b\u306ePostgreSQL\u306b\u306f\u63a5\u7d9a\u3057\u3066\u3044\u307e\u305b\u3093\u3002<br \/>\n\u4ee3\u308f\u308a\u306b\u3001\u30a4\u30f3\u30e1\u30e2\u30ea\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f7f\u3063\u3066\u30c6\u30b9\u30c8\u7528\u306eExpress\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"ts\">import { createApp } from \"..\/..\/src\/app.js\";\nimport type { CalendarEvent } from \"..\/..\/src\/models\/calendarEvent.js\";\nimport { createInMemoryEventRepository } from \"..\/..\/src\/repositories\/eventRepository.js\";\n\nexport function createTestApp(initialEvents: CalendarEvent[] = []) {\n  return createApp({\n    eventRepository: createInMemoryEventRepository(initialEvents),\n  });\n}\n<\/code><\/pre>\n<p>\u3053\u306e\u5f62\u306b\u3057\u3066\u304a\u304f\u3068\u3001\u30c6\u30b9\u30c8\u5074\u3067\u306f\u6b21\u306e\u3088\u3046\u306b\u7c21\u5358\u306b\u30a2\u30d7\u30ea\u3092\u6e96\u5099\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"ts\">const app = createTestApp();\n<\/code><\/pre>\n<p>\u521d\u671f\u30c7\u30fc\u30bf\u304c\u5fc5\u8981\u306a\u5834\u5408\u3082\u3001\u914d\u5217\u3092\u6e21\u3059\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre><code class=\"ts\">const app = createTestApp(createCalendarEvents());\n<\/code><\/pre>\n<p>DB\u307e\u3067\u542b\u3081\u305f\u30c6\u30b9\u30c8\u3082\u5927\u4e8b\u3067\u3059\u304c\u3001\u3059\u3079\u3066\u306eAPI\u30c6\u30b9\u30c8\u3067DB\u3092\u4f7f\u3046\u3068\u6e96\u5099\u304c\u91cd\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u300cAPI\u3068\u3057\u3066\u671f\u5f85\u3057\u305f\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u304b\u300d\u3092\u7d20\u65e9\u304f\u78ba\u8a8d\u3057\u305f\u304b\u3063\u305f\u305f\u3081\u3001\u30a4\u30f3\u30e1\u30e2\u30ea\u3067\u5341\u5206\u3060\u3068\u5224\u65ad\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3053\u306e\u304a\u304b\u3052\u3067\u3001\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3082\u8efd\u304f\u3001\u66f8\u3044\u3066\u3044\u3066\u30b9\u30c8\u30ec\u30b9\u304c\u5c11\u306a\u304b\u3063\u305f\u3067\u3059\u3002<\/p>\n<h2>5. \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306ffactory\u306b\u5206\u3051\u305f<\/h2>\n<p>API\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u3066\u3044\u308b\u3068\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30c7\u30fc\u30bf\u3084\u521d\u671f\u30c7\u30fc\u30bf\u304c\u3069\u3093\u3069\u3093\u5897\u3048\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u6700\u521d\u306f\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u4e2d\u306b\u76f4\u63a5\u66f8\u3044\u3066\u3082\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u5897\u3048\u3066\u304f\u308b\u3068\u300c\u7d50\u5c40\u3053\u306e\u30c6\u30b9\u30c8\u306f\u4f55\u3092\u78ba\u8a8d\u3057\u305f\u3044\u3093\u3060\u3063\u3051\uff1f\u300d\u3068\u306a\u308a\u304c\u3061\u3067\u3059\u3002<br \/>\n\u305d\u3053\u3067\u4eca\u56de\u306f\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u751f\u6210\u3092factory\u306b\u5206\u3051\u307e\u3057\u305f\u3002<\/p>\n<pre><code class=\"ts\">export function createCalendarEventInput(\n  overrides: Partial&lt;CalendarEventInput&gt; = {},\n): CalendarEventInput {\n  return {\n    title: \"Vitest\u3092\u66f8\u304f\",\n    date: \"2026-07-10\",\n    time: \"10:30\",\n    description: \"API\u306e\u4f5c\u6210\u30c6\u30b9\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u3002\",\n    ...overrides,\n  };\n}\n<\/code><\/pre>\n<p>\u57fa\u672c\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u3066\u304a\u304d\u3001\u30c6\u30b9\u30c8\u3054\u3068\u306b\u5909\u3048\u305f\u3044\u3068\u3053\u308d\u3060\u3051\u4e0a\u66f8\u304d\u3057\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u3092\u78ba\u8a8d\u3057\u305f\u3044\u5834\u5408\u306f\u3053\u3046\u66f8\u3051\u307e\u3059\u3002<\/p>\n<pre><code class=\"ts\">createCalendarEventInput({\n  title: \" \",\n  date: \"2026-02-31\",\n  time: \"25:00\",\n});\n<\/code><\/pre>\n<p>\u3053\u306e\u5f62\u306b\u3057\u3066\u304a\u304f\u3068\u3001\u4e0d\u6b63\u5024\u306b\u3057\u3066\u3044\u308b\u30dd\u30a4\u30f3\u30c8\u304c\u3059\u3050\u306b\u5206\u304b\u308a\u307e\u3059\u3002<br \/>\n\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u5206\u3051\u308b\u3060\u3051\u3067\u3001\u30c6\u30b9\u30c8\u672c\u4f53\u304c\u304b\u306a\u308a\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>6. Supertest\u3067API\u3092\u53e9\u304f<\/h2>\n<p>Express API\u306e\u30c6\u30b9\u30c8\u306b\u306fSupertest\u3092\u4f7f\u3044\u307e\u3057\u305f\u3002<br \/>\nSupertest\u3092\u4f7f\u3046\u3068\u3001\u5b9f\u969b\u306b\u30b5\u30fc\u30d0\u30fc\u3092\u30dd\u30fc\u30c8\u3067\u8d77\u52d5\u3057\u306a\u304f\u3066\u3082\u3001Express\u30a2\u30d7\u30ea\u306b\u5bfe\u3057\u3066HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u3088\u3046\u306b\u30c6\u30b9\u30c8\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u4e88\u5b9a\u4f5c\u6210API\u306e\u30c6\u30b9\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"ts\">describe(\"Feature: \u4e88\u5b9aAPI\", () =&gt; {\n  describe(\"Context: \u6709\u52b9\u306a\u4e88\u5b9a\u60c5\u5831\u3067\u4e88\u5b9a\u4f5c\u6210API\u3078\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\", () =&gt; {\n    it(\"Scenario: 5. \u65b0\u3057\u3044\u4e88\u5b9a\u304c\u4f5c\u6210\u3055\u308c\u308b\u3053\u3068\", async () =&gt; {\n      \/\/ Given: \u6709\u52b9\u306a\u4e88\u5b9a\u60c5\u5831\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\n      const app = createTestApp();\n      const payload = createCalendarEventInput();\n\n      \/\/ When: \u4e88\u5b9a\u4f5c\u6210API\u3078POST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3059\u308b\n      const response = await request(app).post(\"\/api\/events\").send(payload);\n\n      \/\/ Then: \u30b9\u30c6\u30fc\u30bf\u30b9201\u3068\u4f5c\u6210\u3055\u308c\u305f\u4e88\u5b9a\u304c\u8fd4\u5374\u3055\u308c\u308b\u3053\u3068\n      expect(response.status).toBe(201);\n      expect(response.body.event).toMatchObject({\n        id: 1,\n        ...payload,\n      });\n    });\n  });\n});\n<\/code><\/pre>\n<p><code>request(app).post(\"\/api\/events\").send(payload)<\/code> \u306e\u3088\u3046\u306b\u66f8\u3051\u308b\u306e\u3067\u3001API\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u611f\u899a\u306b\u8fd1\u3044\u3067\u3059\u3002<br \/>\nController\u3084Service\u306e\u6d41\u308c\u3082\u542b\u3081\u3066\u78ba\u8a8d\u3067\u304d\u308b\u305f\u3081\u3001\u5358\u7d14\u306a\u95a2\u6570\u30c6\u30b9\u30c8\u3088\u308a\u3082\u5b9f\u969b\u306e\u5229\u7528\u306b\u8fd1\u3044\u5b89\u5fc3\u611f\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>7. Gherkin\u98a8\u306b\u3057\u3066\u8aad\u307f\u3084\u3059\u304f\u3057\u305f<\/h2>\n<p>\u4eca\u56de\u306e\u30c6\u30b9\u30c8\u3067\u306f\u3001\u30c6\u30b9\u30c8\u540d\u3092Gherkin\u98a8\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u3067\u3059\u3002<\/p>\n<ul>\n<li><code>Feature<\/code>: \u4f55\u306e\u6a5f\u80fd\u304b<\/li>\n<li><code>Context<\/code>: \u3069\u3093\u306a\u6761\u4ef6\u304b<\/li>\n<li><code>Scenario<\/code>: \u4f55\u3092\u78ba\u8a8d\u3059\u308b\u304b<\/li>\n<li><code>Given<\/code>: \u524d\u63d0<\/li>\n<li><code>When<\/code>: \u64cd\u4f5c<\/li>\n<li><code>Then<\/code>: \u671f\u5f85\u7d50\u679c<\/li>\n<\/ul>\n<p>\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306f\u3001\u52d5\u3051\u3070\u3088\u3044\u3060\u3051\u3067\u306f\u306a\u304f\u3001\u5f8c\u304b\u3089\u8aad\u3093\u3060\u3068\u304d\u306b\u4ed5\u69d8\u304c\u5206\u304b\u308b\u3053\u3068\u3082\u5927\u5207\u3060\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u7279\u306bAPI\u30c6\u30b9\u30c8\u306f\u3001\u753b\u9762\u3088\u308a\u3082\u4ed5\u69d8\u304c\u898b\u3048\u3065\u3089\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3060\u304b\u3089\u3053\u305d\u3001\u30c6\u30b9\u30c8\u540d\u3084\u30b3\u30e1\u30f3\u30c8\u3067\u300c\u3069\u3046\u3044\u3046\u6761\u4ef6\u3067\u3001\u4f55\u3092\u3057\u305f\u3089\u3001\u4f55\u304c\u8fd4\u308b\u306e\u304b\u300d\u3092\u6b8b\u3057\u3066\u304a\u304f\u3068\u3001\u304b\u306a\u308a\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u3001\u4eca\u56de\u306e\u3088\u3046\u306bGherkin\u98a8\u306b\u66f8\u304f\u3068\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u306e\u8868\u793a\u3082\u4ed5\u69d8\u4e00\u89a7\u306e\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-1024x573.png\" alt=\"\" width=\"1024\" height=\"573\" class=\"alignnone size-large wp-image-24697\" srcset=\"https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-1024x573.png 1024w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-300x168.png 300w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-768x430.png 768w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-304x170.png 304w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c-282x158.png 282w, https:\/\/www.ecomottblog.com\/wp-content\/uploads\/2026\/07\/\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u7d50\u679c.png 1532w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h2>8. \u4f7f\u3063\u3066\u307f\u3066\u611f\u3058\u305f\u3053\u3068<\/h2>\n<p>Vitest\u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u30c6\u30b9\u30c8\u3067\u4f7f\u3063\u3066\u307f\u3066\u3001\u601d\u3063\u3066\u3044\u305f\u3088\u308a\u81ea\u7136\u306b\u4f7f\u3048\u308b\u306a\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u8a2d\u5b9a\u304c\u30b7\u30f3\u30d7\u30eb<\/li>\n<li>Supertest\u3068\u7d44\u307f\u5408\u308f\u305b\u3084\u3059\u3044<\/li>\n<li>TypeScript\u3067\u3082\u66f8\u304d\u3084\u3059\u3044<\/li>\n<li>Gherkin\u98a8\u306b\u3059\u308b\u3068\u4ed5\u69d8\u3068\u3057\u3066\u8aad\u307f\u3084\u3059\u3044<\/li>\n<\/ul>\n<p>\u4e00\u65b9\u3067\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u66f8\u304d\u3059\u304e\u308b\u3068\u3001\u3059\u3050\u306b\u8aad\u307f\u3065\u3089\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001factory\u3092\u7528\u610f\u3057\u305f\u308a\u3001\u30c6\u30b9\u30c8\u7528\u30a2\u30d7\u30ea\u3092\u4f5c\u308bhelper\u3092\u5206\u3051\u305f\u308a\u3057\u3066\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u672c\u4f53\u3092\u3067\u304d\u308b\u3060\u3051\u8aad\u307f\u3084\u3059\u304f\u3059\u308b\u3053\u3068\u304c\u5927\u4e8b\u3060\u3068\u601d\u3044\u307e\u3057\u305f\u3002<br \/>\n\u307e\u305f\u3001\u6b63\u5e38\u7cfb\u3060\u3051\u3067\u306a\u304f\u3001404\u3084400\u306e\u3088\u3046\u306a\u7570\u5e38\u7cfb\u3082\u65e9\u3081\u306b\u66f8\u3044\u3066\u304a\u304f\u3068\u5b89\u5fc3\u3067\u3059\u3002<\/p>\n<h2>9. \u307e\u3068\u3081<\/h2>\n<p>\u4eca\u56de\u306f\u3001Vitest\u3092\u4f7f\u3063\u3066Express API\u306e\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u3066\u307f\u305f\u8a71\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<br \/>\nVitest\u306f\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5411\u3051\u306e\u5370\u8c61\u304c\u3042\u308a\u307e\u3057\u305f\u304c\u3001<code>environment: \"node\"<\/code> \u3092\u6307\u5b9a\u3059\u308c\u3070\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3067\u3082\u554f\u984c\u306a\u304f\u4f7f\u3048\u307e\u3059\u3002<br \/>\nSupertest\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001Express API\u306e\u632f\u308b\u821e\u3044\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u3084\u3063\u3066\u3088\u304b\u3063\u305f\u3068\u611f\u3058\u305f\u3053\u3068\u306f\u3001\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<ul>\n<li>DB\u306b\u4f9d\u5b58\u3057\u306a\u3044\u30c6\u30b9\u30c8\u7528\u30a2\u30d7\u30ea\u3092\u7528\u610f\u3057\u305f\u3053\u3068<\/li>\n<li>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092factory\u306b\u5206\u3051\u305f\u3053\u3068<\/li>\n<li>Gherkin\u98a8\u306b\u3057\u3066\u4ed5\u69d8\u3068\u3057\u3066\u3082\u8aad\u307f\u3084\u3059\u304f\u3057\u305f\u3053\u3068<\/li>\n<\/ul>\n<p>\u30c6\u30b9\u30c8\u306f\u3001\u305f\u3060\u6570\u3092\u5897\u3084\u3059\u3082\u306e\u3067\u306f\u306a\u304f\u3001\u5b89\u5fc3\u3057\u3066\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u571f\u53f0\u3060\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306e\u3088\u3046\u306b\u3001API\u306e\u91cd\u8981\u306a\u632f\u308b\u821e\u3044\u3092\u8efd\u304f\u78ba\u8a8d\u3067\u304d\u308b\u5f62\u306b\u3057\u3066\u304a\u304f\u3068\u3001\u5b9f\u88c5\u3092\u5909\u3048\u308b\u3068\u304d\u306e\u4e0d\u5b89\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u30a8\u30b3\u30e2\u30c3\u30c8\u3067\u306f\u3001\u30e2\u30ce\u3065\u304f\u308a\u306b\u5171\u611f\u3057\u3066\u304f\u308c\u308b\u4ef2\u9593\u3092\u52df\u96c6\u4e2d\u3067\u3059\uff01\u5f0a\u793e\u306b\u5c11\u3057\u3067\u3082\u8208\u5473\u304c\u3042\u308b\u65b9\u3001\u305c\u3072\u4e0b\u8a18\u306e\u63a1\u7528\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\uff01<\/p>\n<div style=\"text-align: center; margin: 28px 0 10px;\"><a style=\"display: inline-block; padding: 14px 24px; min-width: 240px; text-align: center; font-size: 16px; font-weight: bold; letter-spacing: .02em; line-height: 1.2; color: #fff; text-decoration: none; border-radius: 14px; border: 1px solid rgba(0,0,0,.12); background: linear-gradient(180deg,#34d058 0%,#28a745 55%,#1f8a38 100%); box-shadow: 0 10px 18px rgba(16,24,40,.16), 0 1px 0 rgba(0,0,0,.18); transform: translateY(0); transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;\" href=\"https:\/\/www.ecomott.co.jp\/recruit\/\" target=\"_blank\" rel=\"noopener\">\u52df\u96c6\u8981\u9805\uff08\u5f53\u793eHP\uff09 \u2192<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u307f\u306a\u3055\u3093\u3001\u3053\u3093\u306b\u3061\u306f\uff01\u30af\u30e9\u30a6\u30c9\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u90e8\u306e\u5bfa\u8c37\u3067\u3059\u3002 7\u6708\u306b\u5165\u308a\u3001\u5317\u6d77\u9053\u3082\u3044\u3088\u3044\u3088\u590f\u672c\u756a\u3068\u3044\u3046\u6c17\u6e29\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u306d\u3002\u6691\u3044\u65e5\u306b\u98f2\u3080\u51b7\u305f\u3044\u70ad\u9178\u6c34\u306f\u6700\u9ad8\u3067\u3059\u304c\u3001\u304a\u8179\u3092\u58ca\u3055\u306a\u3044\u3088\u3046\u306b\u4f53\u8abf\u7ba1\u7406\u306b\u306f\u6c17\u3092\u3064\u3051\u3066\u3044\u304d\u307e\u3059\uff01  [&hellip;]<\/p>\n","protected":false},"author":115,"featured_media":24704,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[485,486],"_links":{"self":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/24674"}],"collection":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/users\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24674"}],"version-history":[{"count":35,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/24674\/revisions"}],"predecessor-version":[{"id":24714,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/posts\/24674\/revisions\/24714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=\/wp\/v2\/media\/24704"}],"wp:attachment":[{"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecomottblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}