Skip to content

test: add Vitest unit tests and CI - #3

Merged
Ellf merged 1 commit into
mainfrom
test/vitest-unit-tests
Nov 4, 2026
Merged

Ellf merged 1 commit into
mainfrom
test/vitest-unit-tests

Conversation

@Ellf

@Ellf Ellf commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

The repo had no automated tests or CI. This adds both.

Tests (76, all passing)

  • test/client.test.ts: API key check, the apiKey and Accept headers, error messages for failed requests, the per-field message when a response doesn't match its schema, unknown-field handling (the loose CourseSchema keeps extra fields, the others drop them), and getRaw debug logging.
  • test/endpoints.test.ts: one row per SDK method, checking the exact URL and query string, including filters, false booleans and the optional user_id on getVideo.
  • test/schemas.test.ts: every response schema accepts a realistic sample, bad data is rejected, and undocumented lecture attachment kinds stay accepted (the 1.0.2 and 1.1.0 fixes).

fetch is faked, so tests need no API key and never call Teachable. All sample data in test/fixtures.ts is made up.

To check the tests catch problems, I broke the source on purpose in three ways (renamed the is_published query param, removed pdf_embed from the known kinds, changed the apiKey header). Four tests failed, as they should.

Tooling

  • Vitest 5.0.5 (dev dependency only; nothing changes in the published package)
  • npm test, npm run test:watch, npm run typecheck (checks src and test)
  • .github/workflows/ci.yml: typecheck, test and build on Node 22 and 24, for PRs and pushes to main
  • README: new Development section

Notes

🤖 Generated with Claude Code

- Client tests: headers, error messages, schema-mismatch errors, debug logging
- Endpoint tests: every method builds the right URL and query string
- Schema tests: sample responses parse, bad data fails, undocumented
  attachment kinds stay accepted
- typecheck script covering src and test
- GitHub Actions workflow: typecheck, test and build on Node 22 and 24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ellf
Ellf force-pushed the test/vitest-unit-tests branch from abeacb2 to cd86b25 Compare November 4, 2026 10:41
@Ellf
Ellf merged commit fa09b31 into main Nov 4, 2026
2 checks passed
@Ellf Ellf mentioned this pull request Nov 4, 2026
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant