Skip to content

[BUG] Invalid use of CommonJS __dirname in ESM test file #2778

@Rajlakshmi-ai

Description

@Rajlakshmi-ai

🐛 What's broken?

The tests/smoke.test.js file uses standard ES Module imports (import { ... } from ...), but relies on the CommonJS __dirname variable to resolve file paths on lines 12, 13, and 101. In a native Node.js ES Module environment, __dirname is undefined and will throw a ReferenceError. While Vitest injects a polyfill for this under the hood, relying on it in an ESM file violates Node.js best practices and can break standard Node execution or stricter linting rules.


📋 Steps to Reproduce

  1. Navigate to the repository file: tests/smoke.test.js.
  2. Observe the ES Module import syntax at the top of the file.
  3. Inspect lines 12 and 13 where __dirname is used in the resolve() function.

✅ Expected Behavior

Path resolution in modern ES Modules should utilize import.meta.dirname (Node >= 20.11) or utilize fileURLToPath(import.meta.url) to construct the directory path safely.


❌ Actual Behavior

The file uses legacy CommonJS globals (__dirname) inside an ES Module.


🔗 Reproduction

Current Structure:

const coreDir = resolve(__dirname, '../core');

Metadata

Metadata

Assignees

Labels

GSSoC-26Official GSSoC 2026 issueacceptedContribution approved for integration into EaseMotion CSSgood first issueGood for newcomersgssoc:approvedApproved for GSSoC contributionshelp wantedExtra attention neededlevel:intermediateRequires moderate project understanding

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions