@naturalcycles/dev-lib 13.33.0 → 13.35.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.
@@ -8,7 +8,7 @@ const fs = require('fs')
8
8
  const runInIDE = process.argv.includes('--runTestsByPath')
9
9
  const ideIntegrationTest = runInIDE && process.argv.some(a => a.endsWith('.integration.test.ts'))
10
10
  const ideManualTest = runInIDE && process.argv.some(a => a.endsWith('.manual.test.ts'))
11
- const { CI } = process.env
11
+ const { CI, GITHUB_ACTIONS } = process.env
12
12
  const cwd = process.cwd()
13
13
 
14
14
  // Set 'setupFilesAfterEnv' only if it exists
@@ -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,
@@ -136,5 +131,7 @@ module.exports = {
136
131
  ancestorSeparator: ' ',
137
132
  },
138
133
  ],
134
+ GITHUB_ACTIONS && 'github-actions', // https://jestjs.io/blog/2022/04/25/jest-28#github-actions-reporter
139
135
  ].filter(Boolean),
136
+ prettierPath: null, // todo: remove when jest has fixed it https://github.com/jestjs/jest/issues/14305
140
137
  }
@@ -2,3 +2,7 @@
2
2
  * Based on: https://github.com/palmerj3/jest-offline/blob/master/index.js
3
3
  */
4
4
  export declare function jestOffline(): void;
5
+ /**
6
+ * Undo/reset the jestOffline() function by allowing network calls again.
7
+ */
8
+ export declare function jestOnline(): void;
@@ -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
- const mitm = createMitm();
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "13.33.0",
3
+ "version": "13.35.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",