graasp / graasp/graasp-api

Optimize tests

Open
#1,515 0 comments 0 reactions 0 assignees View on GitHub
refactor testing
Dominant language
TypeScript
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Goals:
- faster tests
- HTTP Tests that can run on staging
- Unit tests for services, repositories
- repositories: Spawn db, create connection and pass down manager.
- ESM tests?

Problems:
- Meilisearch: the plugin fetches in constructor on plugin register (before the server starts). Worked until now because inside jest, won't work with external server. Mocking dependency (injection) before `build` doesn't work because of the value is registered in `build`.
- Spawn a meilisearch server when moving to a real server?
- Sign in & seeding
- We often need data from another user (eg. check public, private items)
- Should login as another user, inject data, and signed out each time? Sounds inefficient.
- Seed data?
- With HTTP server, we need to sign in in order to call endpoints. Cannot mock authentication anymore.
- Seed might be a quick solution but won't work on staging.

Steps
- [ ] #1516
- [ ] remove `clearDatabase` from all test files
- [ ] remove `mockAuthenticate` -> inject or seed?
- [x] remove `utils.saveX` -> inject or seed?
- [ ] use only external running server for all tests
- transition solution: globalSetup, run app, use globalThis
- [ ] optional: remove inject to use supertest

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.