Comments (12)
I too am finding that with node 8 the mocks are not being reset on calling stop / stopAll
from mock-require.
@zakgrant Node 8 or 8.5? I'm seeing a big difference between how require
works internally from 8 to 8.5.
from mock-require.
@boblauer yeah I am using node 8.5
from mock-require.
I've got a similar issue... but I don't think it's with my version of node. I have something going on where some of the files stop mocking and some don't?
I use setup my mocks in a spec_helper
file that gets loaded before running my express app, like so:
mock('../../lib/docusign', '../../libmocks/docusign_mock');
and then in the test for the that specific lib file, I do:
before(() => {
mock.stop('../../lib/docusign');
docusign = require('../../lib/docusign');
});
after(() => {
mock('../../lib/docusign', '../../libmocks/docusign_mock');
});
With the goal of mocking with fixtures for everything apart from testing the file itself.
It seems to work with some of the lib files but not others?
from mock-require.
Not sure if it's related or not, but I'm finding that it's not catching module import
statements if I import * as fs from 'fs'
. Is it supposed to work with import
as well?
from mock-require.
@alexpchin I think you're right that that is unrelated. Do you mind opening a new issue, with possibly a sample project that reproduces the issue?
@robertmain It does not work with native import
statements. If your code is being transpiled by babel, for example, then it should work, because those import
statements actually get converted to require
statements. However, it's a bit more complex than that.
I would recommend you take a look at https://babeljs.io/repl/#?babili=false&browsers=&build=&builtIns=false&code_lz=Q&debug=false&circleciRepo=&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&version=6.26.0 to see what your code is actually being converted to, I suspect the issue might be in the conversion itself.
from mock-require.
Well my code is TypeScript so, it is running through a transpiler(just not Babel). However it seems not to be working with that.
from mock-require.
I'm also having this issue in node 8.5 :/. Anyone have a workaround?
from mock-require.
@bobbyg603 I ended up using a different package(mock-fs
) instead`
from mock-require.
This is still an issue with latest version, 3.0.1
.
https://travis-ci.org/mightyiam/mock-path-with-simple-spy/jobs/328199961#L1872
from mock-require.
Still an issue. See failing CI here:
mightyiam/mock-path-with-simple-spy#29
from mock-require.
Still an issue for me as well...
from mock-require.
Related Issues (20)
- Using mock require to replace FS module and create a drop in replacement for in-memory filesystems HOT 3
- Use normalize() for consistency in Windows HOT 1
- Issue with mock path HOT 1
- `caller.getTypeName is not a function` HOT 5
- Module._load alignment with Node HOT 2
- travis ci HOT 3
- Impossible to return strings HOT 4
- Unexpected Behaviour HOT 1
- Mocking Nested Dependencies HOT 1
- The mocked module is still loaded HOT 2
- Not mocking package under Jest HOT 7
- mocking nested dependencies HOT 8
- How is this difference from Sinon-like packages? HOT 1
- reRequiring index files returns startMocking HOT 1
- Cannot get to work with an express route module HOT 4
- Introduce a changelog and version tags
- `stop` and `stopAll` should also clear out the cache of previously mocked module HOT 1
- mocking nested dependencies
- Still maintained ? HOT 3
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 mock-require.