@carbonorm/carbonreact 3.3.1 → 3.3.3
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/hoc/setupTests.d.ts +4 -1
- package/dist/index.cjs.js +16 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +16 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hoc/setupTests.tsx +18 -18
- package/src/hoc/validSQL.tsx +2 -1
package/dist/hoc/setupTests.d.ts
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -4253,33 +4253,33 @@ function validSQL$1 (sql) {
|
|
|
4253
4253
|
validSQL.push({ [expect.getState().currentTestName.replaceAll(" ", "_").toLowerCase()]: sql });
|
|
4254
4254
|
}
|
|
4255
4255
|
|
|
4256
|
-
function setupTests () {
|
|
4257
|
-
const
|
|
4256
|
+
function setupTests ({ sqlDirectory = './logs/rest/', logsDirectory = './logs/tests/' } = {}) {
|
|
4257
|
+
const originalWindowLocation = window.location;
|
|
4258
4258
|
const testName = () => expect.getState().currentTestName?.replaceAll(" ", "_").toLowerCase();
|
|
4259
|
-
const validSqlFile = () =>
|
|
4260
|
-
const logsFile = () =>
|
|
4259
|
+
const validSqlFile = () => sqlDirectory + testName() + '.json';
|
|
4260
|
+
const logsFile = () => logsDirectory + testName() + '.log';
|
|
4261
4261
|
/* eslint-disable no-undef */
|
|
4262
4262
|
expect(document).not.toBeNull();
|
|
4263
4263
|
const orig = console;
|
|
4264
4264
|
// @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
|
|
4265
|
-
const
|
|
4265
|
+
const asyncFileLogging = async (...args) => fs.writeFileSync(logsFile(), '\n' + util.inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
|
|
4266
4266
|
// noinspection CommaExpressionJS
|
|
4267
4267
|
global.console = {
|
|
4268
4268
|
...console,
|
|
4269
4269
|
// use jest.fn() to silence, comment out to leave as it is
|
|
4270
|
-
log: (...args) => (carbonnode.isVerbose && orig.log(...args),
|
|
4271
|
-
error: (...args) => (carbonnode.isVerbose && orig.error(...args),
|
|
4272
|
-
warn: (...args) => (carbonnode.isVerbose && orig.warn(...args),
|
|
4273
|
-
info: (...args) => (carbonnode.isVerbose && orig.info(...args),
|
|
4274
|
-
debug: (...args) => (carbonnode.isVerbose && orig.debug(...args),
|
|
4275
|
-
table: (...args) => (carbonnode.isVerbose && orig.table(...args),
|
|
4276
|
-
trace: (...args) => (carbonnode.isVerbose && orig.trace(...args),
|
|
4270
|
+
log: (...args) => (carbonnode.isVerbose && orig.log(...args), asyncFileLogging('log', ...args)),
|
|
4271
|
+
error: (...args) => (carbonnode.isVerbose && orig.error(...args), asyncFileLogging('error', ...args)),
|
|
4272
|
+
warn: (...args) => (carbonnode.isVerbose && orig.warn(...args), asyncFileLogging('warn', ...args)),
|
|
4273
|
+
info: (...args) => (carbonnode.isVerbose && orig.info(...args), asyncFileLogging('info', ...args)),
|
|
4274
|
+
debug: (...args) => (carbonnode.isVerbose && orig.debug(...args), asyncFileLogging('debug', ...args)),
|
|
4275
|
+
table: (...args) => (carbonnode.isVerbose && orig.table(...args), asyncFileLogging('table', ...args)),
|
|
4276
|
+
trace: (...args) => (carbonnode.isVerbose && orig.trace(...args), asyncFileLogging((() => {
|
|
4277
4277
|
const err = new Error();
|
|
4278
4278
|
return err.stack;
|
|
4279
4279
|
})())),
|
|
4280
|
-
group: (...args) => (carbonnode.isVerbose && orig.group(...args),
|
|
4281
|
-
groupCollapsed: (...args) => (carbonnode.isVerbose && orig.groupCollapsed(args),
|
|
4282
|
-
groupEnd: () => (carbonnode.isVerbose && orig.groupEnd(),
|
|
4280
|
+
group: (...args) => (carbonnode.isVerbose && orig.group(...args), asyncFileLogging('group', ...args)),
|
|
4281
|
+
groupCollapsed: (...args) => (carbonnode.isVerbose && orig.groupCollapsed(args), asyncFileLogging('groupCollapsed', ...args)),
|
|
4282
|
+
groupEnd: () => (carbonnode.isVerbose && orig.groupEnd(), asyncFileLogging('groupEnd')),
|
|
4283
4283
|
};
|
|
4284
4284
|
afterEach(async () => {
|
|
4285
4285
|
await react$1.waitFor(async () => {
|
|
@@ -4290,7 +4290,7 @@ function setupTests () {
|
|
|
4290
4290
|
console.log('After each Test (' + expect.getState().currentTestName + ')', expect.getState());
|
|
4291
4291
|
// restore `window.location` to the original `jsdom`
|
|
4292
4292
|
// `Location` object
|
|
4293
|
-
window.location =
|
|
4293
|
+
window.location = originalWindowLocation;
|
|
4294
4294
|
fs.writeFileSync(validSqlFile(), JSON.stringify(validSQL, undefined, 2) ?? '');
|
|
4295
4295
|
}, 65000);
|
|
4296
4296
|
}
|