以行為驅動開發(BDD)打造的井字遊戲網站,採用中文 Gherkin 規格並以自製的極簡 Cucumber runner 驗證互動流程。網站已設定以 Vercel 佈署,可在 https://bdd-tic-tac-toe.vercel.app/ 即時體驗。
features/tic_tac_toe.feature 規格中的互動情境。npm install --package-lock-only # 產生鎖定檔,無需額外套件
npm run serve
指令會先複製 public/ 到 dist/,再啟動簡易靜態伺服器於 http://localhost:4173。
npm run test:bdd
scripts/run-bdd.js) 會解析 Gherkin 規格並執行 bdd/steps.js 中的步驟定義。GameCore,驗證勝負判定、違規提示、紀錄維護等行為。public/ # 靜態網站原始碼
index.html
styles.css
js/
main.js # DOM 綁定與事件處理
game-core.js # 遊戲狀態與規則
bdd/ # 輕量 Cucumber runner 與步驟定義
framework.js
parseFeature.js
steps.js
world.js
features/
tic_tac_toe.feature # 中文 Gherkin 規格
scripts/
build.js # 將 public/ 複製至 dist/
serve.js # 啟動測試/預覽用靜態伺服器
run-bdd.js # 執行 BDD 測試
.github/workflows/deploy.yml 會在推送至 main 分支時:
dist/ 靜態檔案。使用前請於 GitHub 專案設定下列 Secrets:
VERCEL_TOKENVERCEL_ORG_IDVERCEL_PROJECT_ID若需預覽環境,可於 workflow dispatch 時傳入 preview: true,部署將改為 Preview。
另有 .github/workflows/ci.yml 於 PR 與推送時執行測試,確保規格持續通過。
本專案使用 MIT 授權(詳見 LICENSE)。