Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adjust jest for esm and monorepo #57

Merged
merged 11 commits into from
Aug 8, 2024
Merged

Conversation

deekshas8
Copy link
Contributor

@deekshas8 deekshas8 commented Aug 6, 2024

  • Enable Jest to work with esm by setting NODE_OPTIONS=--experimental-vm-modules
  • Move gen-ai-hub/test-util -> gen-ai-hub/src/test-util (else jest throws error)
  • mocking is done locally in each test file since the module path is different for each test path. This will be changed once the core package is created and the function getAiCoreDestination is imported as @sap-ai-sdk/core

Notes:

  • Mocking with Jest and ESM uses unstable_mockModule (docs)
  • Partial mocking is not supported
  • Dependencies have to be imported using await expressions and after the jest.unstable_mockModule call.
    • Mocking does not work if import is done before or using the normal import syntax

@deekshas8 deekshas8 merged commit 63096c3 into main Aug 8, 2024
10 checks passed
@deekshas8 deekshas8 deleted the jest-fix-multi-module branch August 8, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants