decentralized-identity / veramo

A JavaScript Framework for Verifiable Data
https://veramo.io
Apache License 2.0
443 stars 133 forks source link

Jest configuration #1366

Closed nickz-t3 closed 5 months ago

nickz-t3 commented 8 months ago

Bug severity 4

Describe the bug I am trying to integrate Veramo and getting following error upon running jest testing

Warning:  The .env.test file is not located, fallback to default environment configuration
FAIL src/modules/vc_veramo/services/__tests__/issue.unit.spec.ts
  ● Test suite failed to run
    Cannot find module 'uint8arrays' from 'node_modules/@veramo/key-manager/build/key-manager.js'
    Require stack:
      node_modules/@veramo/key-manager/build/key-manager.js
      node_modules/@veramo/key-manager/build/index.js
      src/shared/veramo/setup.ts
      src/modules/vc_veramo/services/__tests__/issue.unit.spec.ts
      17 |
      18 | // Core key manager plugin
    > 19 | import { KeyManager } from '@veramo/key-manager';
         | ^
      20 |
      21 | // Custom key management system for RN
      22 | import { KeyManagementSystem, SecretBox } from '@veramo/kms-local';
      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:4[27](https://github.com/Terminal-3/t3-backend/actions/runs/8462077353/job/23182863538?pr=413#step:8:28):11)
      at Object.<anonymous> (node_modules/@veramo/key-manager/src/key-manager.ts:21:1)
      at Object.<anonymous> (node_modules/@veramo/key-manager/src/index.ts:7:1)
      at Object.<anonymous> (src/shared/veramo/setup.ts:19:1)
      at Object.<anonymous> (src/modules/vc_veramo/services/__tests__/issue.unit.spec.ts:6:1)

Versions Node 20.9

Details I’ve tried:

yarn add uint8arrays
jest.unit.config.ts
moduleNameMapper: {
...
    '^uint8arrays/(.*)$': '<rootDir>/node_modules/uint8arrays/$1',
  },
babel.config.js  
// import assertions
  plugins: [
...
    '@babel/plugin-transform-modules-commonjs',
  ],
};

None of that solves the problem

Any help would be appreciated. Thank you!

nickreynolds commented 7 months ago

We noticed errors related to Jest and uint8arrays after upgrading to ESM, and have dealt with them occasionally when updating dependencies as well.

Could you share a link to your repo so we could help you investigate?

In the meantime, you may want to upgrade your veramo dependencies to version ^6.0.0, so that we're all on the same page.

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.