How savianok/service-test- works
Project type and purpose
• This is an automated testing framework (“service-tests”) built in TypeScript with Mocha, designed to exercise RESTful services (contexts, languages, admin, webhook, etc.), validate database state via SQL, and produce reports (Allure).
• Key files/directories:
– api-methods/: axios wrappers for service endpoints
– sql/: DB connection & queries
– test/: Mocha specs
– test-data/: input fixtures
– helper/ & utils/: shared utilities (base64, object helpers, Allure steps)
– reporterConfig.json: test reporter settings
– CI/CD: Dockerfile, Jenkinsfile
Main components
a. Test Runner & Orchestration
– Mocha CLI (mocharc.js) driving tests in test/*.spec.ts
– Configuration from .env (via .env.example) and reporterConfig.json
b. API Client Layer
– api-methods/*.axios.ts (admin, basicAuth, contexts, languages, webhook)
c. Helper & Utility Modules
– helper/base64_encoded.ts, helper/object.ts
– utils/allureStep.ts for custom Allure reporting steps
d. Data Access Layer
– sql/contexts_db_connection.ts: DB connector
– sql/contexts-service.sql.ts: queries for validation
e. Test Data
– test-data/config-service.data.ts: fixtures used by tests
f. External Systems
– Target REST services: Contexts Service, Config Service, Authentication Service, Webhook endpoint
– Underlying database used by contexts service
g. Reporting & Artifacts
– Allure report generation via reporterConfig.json
h. CI/CD Pipeline
– Dockerfile: build container for tests
– Jenkinsfile: orchestrate build & test steps
Relationships and interactions
• Mocha Runner reads configuration → loads test suites → for each test:
→ uses api-methods to issue HTTP calls to external services
→ optionally runs SQL queries against the DB to assert state
→ logs steps to Allure via utils/allureStep
→ produces pass/fail results and writes reports
• CI/CD (Jenkins) → builds Docker image → injects .env vars → runs Mocha tests → archives Allure artifacts
Architectural patterns & design principles
• Layered Test Architecture: separation of concerns between test definitions, API clients, data helpers, and SQL.
• DRY utilities: helper and utils modules are shared across tests.
• Configuration as code: environment, reporter, and fixtures are externalized.
• Containerized CI pipeline: reproducible environment via Docker.
Detailed component breakdown (to include
– Mocha Runner (entry point, mocharc.js)
– API Methods: admin.axios.ts, contexts.axios.ts, languages.axios.ts, basicAuth.ts, webhook.ts
– Helpers: base64_encoded.ts, object.ts
– Utils: allureStep.ts
– SQL Layer: contexts_db_connection.ts + contexts-service.sql.ts
– Test Suites: contexts.spec.ts, languages.spec.ts
– Test Data: config-service.data.ts
– Configuration: .env (.env.example), reporterConfig.json, tsconfig.json
– Build/Deploy: Dockerfile, Jenkinsfile