Skip to content

Broken test case for filepathToName #11272

Closed as not planned
Closed as not planned

Description

@mukunda-

Issue description

A test case is corrupting the process environment

Expected Behavior

The test case should define and validate the expected behavior. The test case should not change the environment for other tests.

Actual Behavior

The test case is misusing forEach, afterEach and changing the "platform" of the environment that persists to other tests, causing them to fail on Windows.

Steps to reproduce

  1. Run npm test on Windows.

My Environment

Dependency Version
Operating System Windows
TypeORM version 0.3.20

Additional Context

In the filepathToName() test, beforeEach and afterEach is being used inside of a for loop. The for loop should be wrapping the outside of describe, as otherwise those are overwriting the platform (harming every other following test) and running the test incorrectly. This was causing the persistence > basic functionality suite to fail on Windows.

1) persistence > basic functionality
       should save an entity:
     EntityMetadataNotFoundError: No metadata for "Post" was found.
      at DataSource.getMetadata (src\data-source\DataSource.ts:450:30)

When corrected, the test is failing. I can see that when the platform is "darwin", the backslash to forward slash conversion is not used, where the test is expecting that. I believe the test was incorrectly running all cases as "win32" when making the assertions.

I'm unsure of the desired behavior here. It seems like the code has an assumption that Windows-like paths will not be present on non-Windows platforms, and conversion is only done when running on Windows. If that is the case, then we should remove the path conversion comparison from the test case when testing "darwin".

if (process.platform == "win32") { // Only test path conversion on Windows
    const otherOsRes = filepathToName(otherOs)
    expect(winOsRes).to.equal(otherOsRes)
}

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Activity

  1. added a commit that references this issue on Feb 4, 2025
    4c231b6
  2. github-actions commented on Sep 17, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

  3. added this to the 1.0 milestone on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions