@carbonorm/carbonreact 3.3.3 → 3.3.4
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/dist/index.cjs.js +11 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hoc/setupTests.tsx +12 -15
package/package.json
CHANGED
package/src/hoc/setupTests.tsx
CHANGED
|
@@ -8,41 +8,38 @@ export default function ({sqlDirectory = './logs/rest/', logsDirectory = './logs
|
|
|
8
8
|
|
|
9
9
|
const originalWindowLocation = window.location
|
|
10
10
|
|
|
11
|
+
const consoleOriginal = console;
|
|
12
|
+
|
|
11
13
|
const testName = () => expect.getState().currentTestName?.replaceAll(" ", "_").toLowerCase()
|
|
12
14
|
|
|
13
15
|
const validSqlFile = () => sqlDirectory + testName() + '.json';
|
|
14
16
|
|
|
15
17
|
const logsFile = () => logsDirectory + testName() + '.log';
|
|
16
18
|
|
|
17
|
-
/* eslint-disable no-undef */
|
|
18
19
|
expect(document).not.toBeNull();
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
const orig = console;
|
|
22
|
-
|
|
23
21
|
// @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
|
|
24
22
|
const asyncFileLogging = async (...args) => fs.writeFileSync(
|
|
25
23
|
logsFile(),
|
|
26
24
|
'\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true),
|
|
27
25
|
{flag: "a+"});
|
|
28
26
|
|
|
29
|
-
// noinspection CommaExpressionJS
|
|
30
27
|
global.console = {
|
|
31
28
|
...console,
|
|
32
29
|
// use jest.fn() to silence, comment out to leave as it is
|
|
33
|
-
|
|
34
|
-
error: (...args) => (isVerbose &&
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
debug: (...args) => (isVerbose && consoleOriginal.debug(...args), asyncFileLogging('debug', ...args)),
|
|
31
|
+
error: (...args) => (isVerbose && consoleOriginal.error(...args), asyncFileLogging('error', ...args)),
|
|
32
|
+
group: (...args) => (isVerbose && consoleOriginal.group(...args), asyncFileLogging('group', ...args)),
|
|
33
|
+
groupCollapsed: (...args) => (isVerbose && consoleOriginal.groupCollapsed(args), asyncFileLogging('groupCollapsed', ...args)),
|
|
34
|
+
groupEnd: () => (isVerbose && consoleOriginal.groupEnd(), asyncFileLogging('groupEnd')),
|
|
35
|
+
info: (...args) => (isVerbose && consoleOriginal.info(...args), asyncFileLogging('info', ...args)),
|
|
36
|
+
log: (...args) => (isVerbose && consoleOriginal.log(...args), asyncFileLogging('log', ...args)),
|
|
37
|
+
table: (...args) => (isVerbose && consoleOriginal.table(...args), asyncFileLogging('table', ...args)),
|
|
38
|
+
trace: (...args) => (isVerbose && consoleOriginal.trace(...args), asyncFileLogging((() => {
|
|
40
39
|
const err = new Error();
|
|
41
40
|
return err.stack;
|
|
42
41
|
})())),
|
|
43
|
-
|
|
44
|
-
groupCollapsed: (...args) => (isVerbose && orig.groupCollapsed(args), asyncFileLogging('groupCollapsed', ...args)),
|
|
45
|
-
groupEnd: () => (isVerbose && orig.groupEnd(), asyncFileLogging('groupEnd')),
|
|
42
|
+
warn: (...args) => (isVerbose && consoleOriginal.warn(...args), asyncFileLogging('warn', ...args)),
|
|
46
43
|
};
|
|
47
44
|
|
|
48
45
|
afterEach(async () => {
|