You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,16 +13,16 @@
13
13
14
14
NodeJS module mocking for CJS (CommonJS) modules for unit testing purposes. Similar to [proxyquire](https://www.npmjs.com/package/proxyquire), but simpler and safer. Sponsored by [Aeroview](https://aeroview.io).
15
15
16
-
**😃 Easy to Use**
16
+
**😃 Easy to use**
17
17
- Super simple & straightforward documentation
18
18
- Powerful debugging utility
19
19
- Built in Typescript support
20
20
21
-
**🛡 Defensive & Immutable Mocking**
21
+
**🛡 Defensive & immutable mocking**
22
22
- Throws an error if any mocks are unused by module we are mocking
23
23
- Module Cache for mocked modules are always deleted before and after, to minimize side effects and make behavior more predictable and approximate immutability
24
24
25
-
**💪 Robust & Reliable**
25
+
**💪 Robust & reliable**
26
26
- Tiny codebase written in Typescript with only 1 tiny dependency
27
27
28
28
## Example
@@ -94,7 +94,7 @@ However, this can also be a source of confusion.
94
94
95
95
To aid in debugging, you can set the environment variable `CJS_MOCK_DEBUG=1` to see the order of module resolution and mocking.
96
96
97
-
## Partial Mocking
97
+
## Partial mocking
98
98
99
99
You can nest `mock()` for partial mocking of nested dependencies:
100
100
@@ -106,7 +106,7 @@ const m = mock('./foo', {
106
106
});
107
107
```
108
108
109
-
## Do Not Use in Production Environment
109
+
## DO NOT USE IN PRODUCTION
110
110
111
111
Just like for `proxyquire` and other mocking utilities, use of this utility is not recommended in production environments, for the following reasons:
112
112
@@ -130,12 +130,12 @@ This can be useful for debugging, to see if a mock is being used or not, and to
130
130
131
131
Be warned, this may produce a *metric ton* of output. It's sometimes shocking just how many modules are required in a node project, including built-in modules. You may want to limit the output to just the relevant test by only running that test.
132
132
133
-
# Support, Feedback, and Contributions
133
+
# Support, feedback, and contributions
134
134
135
135
- Star this repo if you like it!
136
136
- Submit an [issue](https://github.com/mhweiner/autorel/issues) with your problem, feature request or bug report
137
137
- Issue a PR against `main` and request review. Make sure all tests pass and coverage is good.
138
-
- Write about `autorel` in your blog, tweet about it, or share it with your friends!
138
+
- Write about this project in your blog, tweet about it, or share it with your friends!
139
139
140
140
# Sponsorship
141
141
@@ -150,6 +150,13 @@ Want to sponsor this project? [Reach out to me via email](mailto:mhweiner234@gma
150
150
151
151
Aeroview is a lightning-fast, developer-friendly, and AI-powered logging IDE. Get started for free at [https://aeroview.io](https://aeroview.io).
152
152
153
+
# Other useful libraries
154
+
155
+
-[autorel](https://github.com/mhweiner/autorel): Automatic versioning, deployment, and release notes generation
156
+
-[hoare](https://github.com/mhweiner/hoare): A simple, powerful, and flexible testing library for Typescript
157
+
-[jsout](https://github.com/mhweiner/jsout): A simple, powerful, and flexible logging library for Javascript
158
+
-[lambdaconf](https://github.com/mhweiner/lambdaconf): A simple, powerful, and flexible configuration library for Typescript that supports AWS Secrets Manager and dynamic configuration loading
0 commit comments