Skip to content

fix: standardize database credentials with environment variables and …#100

Merged
Julien-R44 merged 1 commit intoJulien-R44:mainfrom
thisisnkc:fix/tests
Dec 26, 2025
Merged

fix: standardize database credentials with environment variables and …#100
Julien-R44 merged 1 commit intoJulien-R44:mainfrom
thisisnkc:fix/tests

Conversation

@thisisnkc
Copy link
Contributor

Description

This PR refactors the test suite to improve reliability, maintainability, and developer experience. The changes address Node.js compatibility issues, centralize database configuration, improve test cleanup behavior, and standardize test naming conventions.


Summary of Changes

1. Fix Node.js Compatibility in File Driver

Fixed a crash in the file driver’s cache pruning logic when running on Node.js versions prior to v20.12.0.

Older Node.js versions do not expose the parentPath property on fs.Dirent objects, which caused path resolution to fail during pruning.

Before

const filePath = join(dirEntry.parentPath, dirEntry.name)

After

const basePath =
  typeof dirEntry.parentPath === 'string'
    ? dirEntry.parentPath
    : dirEntry.path

const filePath = join(basePath, dirEntry.name)

This ensures compatibility across all supported Node.js versions.


2. Centralize Database Credentials

Database credentials are now configured via environment variables instead of being hardcoded in individual test files.

Changes made

  • Added centralized exports:

    • MYSQL_CREDENTIALS
    • POSTGRES_CREDENTIALS

    in:

    tests/helpers/index.ts
    
  • Updated .env.example with all supported configuration options

  • Refactored all database driver tests to import credentials from the shared helpers module


3. Improve Test Cleanup Reliability

Replaced manual disconnect() calls with Japa’s cleanup() hook to ensure resources are released even when tests fail.

Before

test('example', async ({ assert }) => {
  const connection = new Connection()
  assert.equal(...)
  await connection.disconnect()
})

After

test('example', async ({ assert, cleanup }) => {
  const connection = new Connection()
  cleanup(() => connection.disconnect())
  assert.equal(...)
})

4. Standardize Test Group Naming

Applied consistent sentence-case naming conventions across all test groups.

Examples:

  • Redis driver
  • Knex | Postgres driver
  • Kysely | Mysql driver

Outcome

  • Improved Node.js compatibility
  • Centralized and configurable database setup
  • More reliable test cleanup
  • Consistent and readable test naming

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

⚠️ No Changeset found

Latest commit: c876b72

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Julien-R44 Julien-R44 merged commit ce8f39d into Julien-R44:main Dec 26, 2025
8 checks passed
@Julien-R44
Copy link
Owner

Thanks !

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.

2 participants