Comments (3)
@brianzinn it's not so easy understand the whole setup, but! obviously, when you mock something with esmock, imports are comes from different module(s) (which is created on the fly) - so, object comparison by value, by using instanceof operator, etc. don't work as you may expect. In that particular case, if you want to compare some object exported from 'entities.js' with other object from the same file, you have mock that object with pre-defined value (doesn't matter which value - real object imported at the top of test file, or just unique symbol if code doesn't call object methods) in every test.
from esmock.
thanks @koshic - I will try actually to pass them myself. I'm not sure why I didn't think of trying that. It's a bit of a paradigm shift thinking about the module loader. I can't try till later today - will report back. cheers.
esmock({
...,
{
...
'../pathToEntities': Entities
}
)
from esmock.
yes - that was it 🤦♂️ my tests are becoming more succinct as i make changes - this way of mocking guides me towards only mocking immediate dependencies.
from esmock.
Related Issues (20)
- yarn pnp issues HOT 14
- Is it possible to mock json imports with assert? HOT 6
- Support Yarn PnP resolver out of the box HOT 11
- Get rid of old Node versions support HOT 8
- resolve error introduced with 2.5.2 HOT 10
- Error when mocking a file that exports an array. HOT 1
- c8 incorrect branch coverage; modules and `import` globals HOT 11
- how to mock globalThis HOT 4
- import('node:fs/promises') called within a library does not seem to be replaced HOT 30
- Path alias support HOT 1
- Unexpected strict mode reserved word syntax error when mocking express HOT 2
- incompatible with eslint-plugin-import HOT 3
- No support for subpath patterns? HOT 14
- Version 2.6.3 changed the way to mock libraries HOT 7
- ESMock seems to wrongfully alter Sinon stubs. HOT 1
- Using `import:` to mock globals messes up coverage (with c8) HOT 7
- [Question] Is it possible to mock indirect imports? HOT 10
- Scoped mocks failing with pnpm but working with npm HOT 9
- upstream issue, worker threads unable to register loader HOT 1
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.