Comments (2)
Also, I'm puzzled by the fact that your example code is not calling mockRequest on an object.
const req1 = mockRequest({ awesome: 'value' });
I could expect something like
const mock = require('jest-mock-req-res');
const req1 = mock.mockRequest({ awesome: 'value' });
from jest-mock-req-res.
Hi,
Sorry for not getting back to you earlier.
I'm really not sure what could be the problem with your project without additional details. I haven't had any issues using this package with either Typescript or JavaScript, as it's pretty minimal. If you could provide a minimal project setup reproducing the issue, I can try to troubleshoot it.
Regarding your second comment, the library exports two factory functions that you can use to create mock objects. The code you wrote is correct, but you can accomplis the same thing using named imports, which are more common when working with Typescript code. The code would look like:
import { mockRequest } from 'jest-mock-req-res';
const req1 = mockRequest({ awesome: 'value' });
Note that the same could be done in vanilla JavaScript like this:
const { mockRequest } = require('jest-mock-req-res');
const req1 = mockRequest({ awesome: 'value' });
Also, the import
syntax is perfectly valid if working with JavaScript modules (using a file with extension .mjs
will work out-of-the-box in any version of NodeJS over 13.2.0).
ESM Docs for NodeJS
Original announcement
from jest-mock-req-res.
Related Issues (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 jest-mock-req-res.