Skip to content

Bug: Mocked file path suffix checks fail on Windows #89

@utkarsh232005

Description

@utkarsh232005

📝 Description

In src/__tests__/version-check.test.ts, the mocked implementation of readFileSync uses path.endsWith(...) to validate file paths. These checks assume POSIX-style forward-slash (/) directory separators.

Because Windows uses backslashes (\) for file paths, the .endsWith() suffix matches fail when running the test suite on Windows environments, causing tests to break unexpectedly.

📍 Location

  • File: src/__tests__/version-check.test.ts
  • Affected Lines: ~113–115 (Also applies to lines 125–126, 136–140, and 150–154)

💥 Current Code Snippet

vi.mocked(readFileSync).mockImplementation((path) => {
  if (typeof path === 'string' && path.endsWith('src/package.json')) {
    return JSON.stringify({ version: '2.3.4' });
  }
  throw new Error('File not found');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    BeginnerSkill typebugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions