@carbonorm/carbonreact 3.3.0 → 3.3.1
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 +1 -1
- package/dist/index.cjs.js +42 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +42 -40
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hoc/setupTests.tsx +43 -40
- package/src/index.ts +1 -0
package/dist/hoc/setupTests.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function (): void;
|
package/dist/index.cjs.js
CHANGED
|
@@ -4253,45 +4253,47 @@ function validSQL$1 (sql) {
|
|
|
4253
4253
|
validSQL.push({ [expect.getState().currentTestName.replaceAll(" ", "_").toLowerCase()]: sql });
|
|
4254
4254
|
}
|
|
4255
4255
|
|
|
4256
|
-
|
|
4257
|
-
const
|
|
4258
|
-
const
|
|
4259
|
-
const
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4256
|
+
function setupTests () {
|
|
4257
|
+
const origionalWindowLocation = window.location;
|
|
4258
|
+
const testName = () => expect.getState().currentTestName?.replaceAll(" ", "_").toLowerCase();
|
|
4259
|
+
const validSqlFile = () => './logs/rest/' + testName() + '.json';
|
|
4260
|
+
const logsFile = () => './logs/tests/' + testName() + '.log';
|
|
4261
|
+
/* eslint-disable no-undef */
|
|
4262
|
+
expect(document).not.toBeNull();
|
|
4263
|
+
const orig = console;
|
|
4264
|
+
// @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
|
|
4265
|
+
const superLogger = async (...args) => fs.writeFileSync(logsFile(), '\n' + util.inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
|
|
4266
|
+
// noinspection CommaExpressionJS
|
|
4267
|
+
global.console = {
|
|
4268
|
+
...console,
|
|
4269
|
+
// use jest.fn() to silence, comment out to leave as it is
|
|
4270
|
+
log: (...args) => (carbonnode.isVerbose && orig.log(...args), superLogger('log', ...args)),
|
|
4271
|
+
error: (...args) => (carbonnode.isVerbose && orig.error(...args), superLogger('error', ...args)),
|
|
4272
|
+
warn: (...args) => (carbonnode.isVerbose && orig.warn(...args), superLogger('warn', ...args)),
|
|
4273
|
+
info: (...args) => (carbonnode.isVerbose && orig.info(...args), superLogger('info', ...args)),
|
|
4274
|
+
debug: (...args) => (carbonnode.isVerbose && orig.debug(...args), superLogger('debug', ...args)),
|
|
4275
|
+
table: (...args) => (carbonnode.isVerbose && orig.table(...args), superLogger('table', ...args)),
|
|
4276
|
+
trace: (...args) => (carbonnode.isVerbose && orig.trace(...args), superLogger((() => {
|
|
4277
|
+
const err = new Error();
|
|
4278
|
+
return err.stack;
|
|
4279
|
+
})())),
|
|
4280
|
+
group: (...args) => (carbonnode.isVerbose && orig.group(...args), superLogger('group', ...args)),
|
|
4281
|
+
groupCollapsed: (...args) => (carbonnode.isVerbose && orig.groupCollapsed(args), superLogger('groupCollapsed', ...args)),
|
|
4282
|
+
groupEnd: () => (carbonnode.isVerbose && orig.groupEnd(), superLogger('groupEnd')),
|
|
4283
|
+
};
|
|
4284
|
+
afterEach(async () => {
|
|
4285
|
+
await react$1.waitFor(async () => {
|
|
4286
|
+
expect(carbonnode.checkAllRequestsComplete()).toEqual(true);
|
|
4287
|
+
}, { timeout: 3000, interval: 1000 });
|
|
4288
|
+
// this must be a dynamic import to avoid loading dependencies out of order
|
|
4289
|
+
// await waitForTrailingRequests({testPassed: true, timeout: 12000})
|
|
4290
|
+
console.log('After each Test (' + expect.getState().currentTestName + ')', expect.getState());
|
|
4291
|
+
// restore `window.location` to the original `jsdom`
|
|
4292
|
+
// `Location` object
|
|
4293
|
+
window.location = origionalWindowLocation;
|
|
4294
|
+
fs.writeFileSync(validSqlFile(), JSON.stringify(validSQL, undefined, 2) ?? '');
|
|
4295
|
+
}, 65000);
|
|
4296
|
+
}
|
|
4295
4297
|
|
|
4296
4298
|
exports.eUpdateInsertMethod = void 0;
|
|
4297
4299
|
(function (eUpdateInsertMethod) {
|
|
@@ -4516,6 +4518,7 @@ exports.reports = reports;
|
|
|
4516
4518
|
exports.scrollIntoView = ScrollIntoViewDirective;
|
|
4517
4519
|
exports.setCookies = setCookies;
|
|
4518
4520
|
exports.setUrl = setUrl;
|
|
4521
|
+
exports.setupTests = setupTests;
|
|
4519
4522
|
exports.toDataURL = toDataURL;
|
|
4520
4523
|
exports.updateRestfulObjectArrays = updateRestfulObjectArrays;
|
|
4521
4524
|
exports.uploadImage = uploadImage;
|