Comments (8)
Thanks for the support! I'll try to run it later or tomorrow again with experimental mode and the full path, see what works.
from esmock.
@PatrickHeneise thanks and regards hoping everything is good for you this holiday season. Feel free to re-open or message any time
from esmock.
Related PnP-compatibility changes were made for this issue #176
@koshic do you know of a solution for using esmock with PnP? It seems to still not be working. @koshic @PatrickHeneise esmock could be updated with changes you might recommend for resolving this issue
from esmock.
@iambumblehead pnpm and yarn PnP are very different things )
I can answer about PnP only:
- yarn unplug esmock to place it somewhere inside .yarn/unplugged dir
- yarn node --loader $(yarn node --input-type=module -e 'console.log((await import("module")).default.findPnpApi(".").resolveRequest("esmock",
${process.cwd()}/dummy.js
, { conditions: new Set(["import"]) }))')
Sure, we can create simple wrapper for second step - do the same to get esmock path, dynamically import esmock and export load + resolve hooks (my reason why I requested changes in 'is esmock loaded?' fn).
from esmock.
@koshic ah I see pnpm is a different thing!
@PatrickHeneise which moduleId is not found? Would you share the full message? If you use esmock with --experimental-import-meta-resolve
do your tests run correctly?
from esmock.
@PatrickHeneise would you try esmock using the full path to the module for which moduleId is not found? For example, if the '@google-cloud/secret-manager' moduleId is not found, try something like,
const { fetchVariable } = await esmock('../lib/fetchVariable.js', {
- '@google-cloud/secret-manager': {
+ '/full/path/to/node_modules/@google-cloud/secret-manager': {
// ...
}
})
another way...
const { fetchVariable } = await esmock('../lib/fetchVariable.js', {
- '@google-cloud/secret-manager': {
+ [new URL('@google-cloud/secret-manager', import.meta.url)]: {
// ...
}
})
from esmock.
@PatrickHeneise also feel free to submit a failing test and I will merge and try to resolve per https://github.com/iambumblehead/esmock/blob/master/CONTRIBUTING.md
from esmock.
tomorrow ... closing this as I don't have capacity at the moment. Will run the test when I get back to this project. Thanks though!
from esmock.
Related Issues (20)
- Error: invalid moduleId when trying to stub a module dependency ES6 HOT 4
- What about Yarn PnP support? HOT 13
- Minified sources in esmock package HOT 4
- Invalid check in esmockIsLoader.js HOT 8
- Unable to mock the native node:zlib module with TypeScript and Mocha/Chai/Sinon. HOT 2
- Partial mocking not working as expected HOT 18
- strictest silently allows to pass {} or undefined as defs -> real dependencies are used HOT 1
- Is it possible to mock `process.cwd()`? HOT 6
- Overriding `globalThis` per mock HOT 6
- Node 20.x: import.meta.resolve is not a promise anymore HOT 1
- Unexpected token 'delete' HOT 9
- Mock a package globally HOT 1
- Add factory method(s) to avoid code duplication / custom wrappers HOT 4
- `invalid moduleId` error when using tsx HOT 16
- Mock dependency HOT 8
- Is it possible to mock a binary's imports? HOT 6
- Mocking a file with a hashbang using the `import` key fails HOT 7
- Error when using `import` key with modules that have CJS imports HOT 9
- 2.3.4 - 'RangeError [ERR_UNKNOWN_MODULE_FORMAT]: Unknown module format: undefined' HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esmock.