@@ -23,6 +23,8 @@ yarn test:watch
2323
2424## Database-Specific Tests
2525
26+ The project uses shell scripts to set up the proper environment for each database type before running tests.
27+
2628### SQLite Tests
2729
2830``` bash
@@ -50,6 +52,12 @@ yarn test:mysql test/login.test.ts
5052yarn test:mysql -- --grep " authentication"
5153```
5254
55+ The MySQL test script (` scripts/test-mysql.sh ` ) automatically:
56+ - Sets up environment variables for MySQL
57+ - Waits for MySQL to be ready (with retry logic)
58+ - Creates the test database if it doesn't exist
59+ - Handles authentication with ` MYSQL_PWD ` environment variable
60+
5361### PostgreSQL Tests
5462
5563``` bash
@@ -63,6 +71,35 @@ yarn test:postgresql test/login.test.ts
6371yarn test:postgresql -- --grep " authentication"
6472```
6573
74+ The PostgreSQL test script (` scripts/test-postgresql.sh ` ) automatically:
75+ - Sets up environment variables for PostgreSQL
76+ - Waits for PostgreSQL to be ready (with retry logic)
77+ - Creates the test database if it doesn't exist
78+ - Uses ` PGPASSWORD ` for authentication
79+
80+ ## Test Scripts
81+
82+ The project includes shell scripts in the ` scripts/ ` directory that handle database setup and test execution:
83+
84+ ### ` scripts/test-sqlite.sh `
85+ - Sets ` DB_CONNECTOR=sqlite ` environment variable
86+ - Runs tests against SQLite database
87+ - No additional setup required
88+
89+ ### ` scripts/test-mysql.sh `
90+ - Sets up MySQL environment variables
91+ - Waits for MySQL connection with retry logic (up to 10 attempts)
92+ - Creates test database if it doesn't exist
93+ - Sets ` MYSQL_PWD ` for authentication
94+ - Provides helpful error messages if MySQL is not accessible
95+
96+ ### ` scripts/test-postgresql.sh `
97+ - Sets up PostgreSQL environment variables
98+ - Waits for PostgreSQL connection with retry logic (up to 10 attempts)
99+ - Creates test database if it doesn't exist
100+ - Uses ` PGPASSWORD ` for authentication
101+ - Provides helpful error messages if PostgreSQL is not accessible
102+
66103## Test Files Overview
67104
68105| File | Description |
@@ -121,7 +158,7 @@ For PostgreSQL tests, you need a running PostgreSQL instance. The tests use thes
121158- ** Host** : ` localhost `
122159- ** Port** : ` 5432 `
123160- ** User** : ` postgres `
124- - ** Password** : ` postgres `
161+ - ** Password** : ` 123 `
125162- ** Database** : ` test_db `
126163
127164### Environment Variables
@@ -142,7 +179,7 @@ export DB_NAME=your-test-db
142179``` bash
143180# Start PostgreSQL container for testing
144181docker run --name postgres-test \
145- -e POSTGRES_PASSWORD=postgres \
182+ -e POSTGRES_PASSWORD=123 \
146183 -e POSTGRES_DB=test_db \
147184 -p 5432:5432 \
148185 -d postgres:13
@@ -285,13 +322,25 @@ yarn lint --fix
285322
286323## Continuous Integration
287324
288- The project includes CI configuration that:
325+ The project includes CI configuration (` .github/workflows/ci.yml ` ) that:
326+
327+ 1 . ** Runs tests against all databases** :
328+ - SQLite (no additional setup required)
329+ - MySQL (with MariaDB 10.5 service and health checks)
330+ - PostgreSQL (with PostgreSQL 13 service and health checks)
331+
332+ 2 . ** Database setup in CI** :
333+ - Installs database clients (` mariadb-client ` , ` postgresql-client ` )
334+ - Uses health checks to ensure databases are ready before testing
335+ - Sets up proper environment variables for each database type
336+
337+ 3 . ** Additional checks** :
338+ - Checks TypeScript types
339+ - Runs linting
340+ - Builds the module
341+ - Builds documentation
289342
290- 1 . Runs tests against SQLite, MySQL, and PostgreSQL
291- 2 . Checks TypeScript types
292- 3 . Runs linting
293- 4 . Builds the module
294- 5 . Builds documentation
343+ The CI workflow automatically handles database setup and teardown, making it easy to run tests in a clean environment.
295344
296345## Debugging Tests
297346
0 commit comments