Skip to content

Repository files navigation

ChatBet API Testing

Cypress test suite for the ChatBet API with Mochawesome reports.

Quick Start

npm install
npm test              # Run all tests
npm run report        # Open HTML report in browser

# Run specific suites
npm run test:simple-bet
npm run test:combo-bet
npm run test:errors

What's Inside

3 Test Suites:

  • TS01-simple-bet.cy.js - Place single bet flow (7 tests)
  • TS02-combo-bet.cy.js - Multiple selections combo (9 tests)
  • TS03-error-validation.cy.js - Error handling (12 tests)

Config Files:

  • cypress/fixtures/simple-bet-config.json
  • cypress/fixtures/combo-bet-config.json
  • cypress/fixtures/error-tests-config.json

Test Results

All 28 tests passing ✅

TS01: 7/7 passing  (3s) - Stake: $0.50
TS02: 9/9 passing  (5s) - Stake: $0.30
TS03: 12/12 passing (5s) - No bets placed
Total: 15s | $0.80 per test run

Reports

Automatic HTML report generated after each run:

  • Location: cypress/reports/index.html
  • View: npm run report
  • Includes: Screenshots, execution times, request/response logs
  • Screenshots captured on test failures

Screenshots saved in cypress/screenshots/

Configuration

Edit cypress.config.js to change:

  • API base URL
  • Test credentials (userId, userKey)
  • Report settings

Or set in test config files:

{
  "sport_id": 1,
  "tournament_id": 101,
  "stake": 100.00
}

Project Structure

cypress/
├── e2e/
│   ├── TS01-simple-bet.cy.js
│   ├── TS02-combo-bet.cy.js
│   └── TS03-error-validation.cy.js
├── fixtures/
│   ├── simple-bet-config.json
│   ├── combo-bet-config.json
│   └── error-tests-config.json
├── support/
│   ├── commands.js          # Custom Cypress commands
│   └── e2e.js
└── reports/                 # Mochawesome HTML/JSON reports

Custom Commands

All in cypress/support/commands.js:

  • cy.generateToken() - Get auth token
  • cy.getUserBalance(token) - Get balance
  • cy.getFixtures(tournamentId) - Get fixtures
  • cy.getOdds({...}) - Get odds for fixture
  • cy.placeBet({...}) - Place single/combo bet

API Issues Found

During testing, found 5 validation issues where API accepts invalid data:

  1. Invalid fixture IDs accepted
  2. Invalid market types accepted
  3. Bets exceeding balance processed
  4. Non-existent fixtures in combos accepted
  5. Missing fixtures return 200

See API_VALIDATION_ISSUES.md for details.

Notes

  • Tests use cypress-plugin-api for better API testing
  • All test names follow TS/TC convention (see NAMING_CONVENTION.md)
  • Tests are parameterized - easy to modify test data
  • HTML reports auto-generated with embedded screenshots
  • Screenshots captured automatically on test failures

Balance Warning:

  • Test account balance depletes with each run ($0.80 per run)
  • TS01 places $0.50 bet, TS02 places $0.30 bet
  • If tests fail with 400 errors, balance is insufficient
  • Adjust stakes in config files if needed

Docs

  • TEST_PLAN.md - Test cases and coverage
  • NAMING_CONVENTION.md - TS/TC naming explained
  • API_VALIDATION_ISSUES.md - Known API bugs
  • DESIGN_SOLUTION.md - Real-time data architecture

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages