Skip to content

Conversation

david-luna
Copy link
Contributor

Which problem is this PR solving?

When running test-all-versions we may get an error related to ESM modules. An example

> @opentelemetry/[email protected] test
  > nyc mocha 'test/**/*.test.ts'
  
  
   Exception during run: Error: Directory import '/home/runner/work/opentelemetry-js-contrib/opentelemetry-js-contrib/packages/instrumentation-pg/src' is not supported resolving ES modules imported from /home/runner/work/opentelemetry-js-contrib/opentelemetry-js-contrib/packages/instrumentation-pg/test/pg-pool.test.ts
      at finalizeResolution (node:internal/modules/esm/resolve:262:11)
      at moduleResolve (node:internal/modules/esm/resolve:864:10)
      at defaultResolve (node:internal/modules/esm/resolve:990:11)
      at ModuleLoader.#cachedDefaultResolve (node:internal/modules/esm/loader:749:20)
      at ModuleLoader.resolve (node:internal/modules/esm/loader:726:38)
      at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:312:38)
      at ModuleJob.#link (node:internal/modules/esm/module_job:208:49) {
    code: 'ERR_UNSUPPORTED_DIR_IMPORT',
    url: 'file:///home/runner/work/opentelemetry-js-contrib/opentelemetry-js-contrib/packages/instrumentation-pg/src'
  }

The reason might be that the test file is considered an ESM module in a specific situations (no sure which one yet) and ESM does not accept the import of directories.

Short description of the changes

  • update imports in test files

@maryliag
Copy link
Contributor

maryliag commented Sep 4, 2025

looks like tests are still failing 😢

@david-luna
Copy link
Contributor Author

looks like tests are still failing 😢

Yeah, but the error is not consistent. Sometimes I get problems loading pg module and others it complains about loading a file in the test 🤔

@david-luna
Copy link
Contributor Author

david-luna commented Sep 4, 2025

@maryliag it's a problem in the test process. Superseded by #3017

@david-luna david-luna closed this Sep 4, 2025
@david-luna david-luna deleted the pg-test-esm-issue branch September 4, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants