Skip to content

ESM broken #29

Closed
Closed
@tiagoporto

Description

@tiagoporto
  • cli-testing-library version: 2.0.2
  • Testing Framework and version: Node test runner @ v23.4.0

Relevant code or config:

Importing as an ESM module:

import { render } from 'cli-testing-library'

What you did:

Just set up the tool using mjs.

What happened:

Screenshot 2025-01-11 at 9 45 31 AM

Problem description:

Node ESM modules doesn't support __dirname.

https://github.com/crutchcorn/cli-testing-library/blob/main/src/pure.ts#L20

Suggested solution:

Replace __dirname by

import path from 'path'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

The current workaround was using cjs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions