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

mock modules that aren't found, test failing #127

Merged
merged 12 commits into from Aug 25, 2022

Conversation

iambumblehead
Copy link
Owner

@iambumblehead iambumblehead commented Aug 25, 2022

closes #126

@cawa-93 when esmock is chained with other "--loader" modules (node v18) each module loader must call await nextResolve and this call breaks the loader and this is demonstrated with the failing test here.

      duration_ms: 0.008446949
      failureType: 'testCodeFailure'
      error: "Cannot find package 'vue' imported from /home/bumble/software/esmock/tests/local/notinstalledVueComponent.js"
      code: 'ERR_MODULE_NOT_FOUND'
      stack: |-
        new NodeError (node:internal/errors:387:5)
        packageResolve (node:internal/modules/esm/resolve:909:9)
        moduleResolve (node:internal/modules/esm/resolve:958:20)
        defaultResolve (node:internal/modules/esm/resolve:1173:11)
        nextResolve (node:internal/modules/esm/loader:173:28)
        resolve (file:///home/bumble/software/esmock/src/esmockLoader.js:50:13)
        nextResolve (node:internal/modules/esm/loader:173:28)
        ESMLoader.resolve (node:internal/modules/esm/loader:852:30)
        ESMLoader.getModuleJob (node:internal/modules/esm/loader:439:18)
        ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)

Feel free to try anything out here. I will try and think about more and experiment to try and get around the runtime error.

@iambumblehead
Copy link
Owner Author

@cawa-93 if we skip calling nextResolve for this specific situation the tests pass I think this will work but I'm taking a break now :)

@iambumblehead
Copy link
Owner Author

the tests should be passing but there is a seemingly random issue that affecting the 18.x pipeline

@iambumblehead
Copy link
Owner Author

this issue causes the ci to fail avajs/ava#3091

@iambumblehead iambumblehead merged commit 968b357 into master Aug 25, 2022
@iambumblehead iambumblehead deleted the mock-modules-that-arent-found branch August 25, 2022 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.

Can't mock package 'vue' if it doesn't installed
2 participants