@naturalcycles/dev-lib 13.33.0 → 13.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cfg/jest.config.js +1 -5
- package/dist/jestOffline.util.d.ts +4 -0
- package/dist/jestOffline.util.js +10 -2
- package/package.json +1 -1
package/cfg/jest.config.js
CHANGED
|
@@ -87,11 +87,6 @@ module.exports = {
|
|
|
87
87
|
skipNodeResolution: true,
|
|
88
88
|
testEnvironment: 'node',
|
|
89
89
|
errorOnDeprecated: true,
|
|
90
|
-
snapshotFormat: {
|
|
91
|
-
// todo: remove when jest@29 makes it default
|
|
92
|
-
escapeString: false,
|
|
93
|
-
printBasicPrototype: false,
|
|
94
|
-
},
|
|
95
90
|
restoreMocks: true,
|
|
96
91
|
unmockedModulePathPatterns: [],
|
|
97
92
|
setupFilesAfterEnv,
|
|
@@ -137,4 +132,5 @@ module.exports = {
|
|
|
137
132
|
},
|
|
138
133
|
],
|
|
139
134
|
].filter(Boolean),
|
|
135
|
+
prettierPath: null, // todo: remove when jest has fixed it https://github.com/jestjs/jest/issues/14305
|
|
140
136
|
}
|
package/dist/jestOffline.util.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jestOffline = void 0;
|
|
3
|
+
exports.jestOnline = exports.jestOffline = void 0;
|
|
4
4
|
const testing_1 = require("./testing");
|
|
5
5
|
const LOCAL_HOSTS = ['localhost', '127.0.0.1'];
|
|
6
6
|
const detectLeaks = process.argv.some(a => a.includes('detectLeaks'));
|
|
7
|
+
let mitm;
|
|
7
8
|
/**
|
|
8
9
|
* Based on: https://github.com/palmerj3/jest-offline/blob/master/index.js
|
|
9
10
|
*/
|
|
@@ -14,7 +15,7 @@ function jestOffline() {
|
|
|
14
15
|
}
|
|
15
16
|
(0, testing_1.jestLog)('jest offline mode');
|
|
16
17
|
const createMitm = require('mitm');
|
|
17
|
-
|
|
18
|
+
mitm ||= createMitm();
|
|
18
19
|
mitm.on('connect', (socket, opts) => {
|
|
19
20
|
const { host } = opts;
|
|
20
21
|
if (!LOCAL_HOSTS.includes(host)) {
|
|
@@ -24,3 +25,10 @@ function jestOffline() {
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
exports.jestOffline = jestOffline;
|
|
28
|
+
/**
|
|
29
|
+
* Undo/reset the jestOffline() function by allowing network calls again.
|
|
30
|
+
*/
|
|
31
|
+
function jestOnline() {
|
|
32
|
+
mitm?.disable();
|
|
33
|
+
}
|
|
34
|
+
exports.jestOnline = jestOnline;
|