@carbonorm/carbonreact 3.3.1 → 3.3.2

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.
@@ -1 +1,4 @@
1
- export default function (): void;
1
+ export default function ({ sqlDirectory, logsDirectory }: {
2
+ sqlDirectory: string;
3
+ logsDirectory: string;
4
+ }): void;
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 origionalWindowLocation = window.location;
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 = () => './logs/rest/' + testName() + '.json';
4260
- const logsFile = () => './logs/tests/' + testName() + '.log';
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 superLogger = async (...args) => fs.writeFileSync(logsFile(), '\n' + util.inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
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), 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((() => {
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), superLogger('group', ...args)),
4281
- groupCollapsed: (...args) => (carbonnode.isVerbose && orig.groupCollapsed(args), superLogger('groupCollapsed', ...args)),
4282
- groupEnd: () => (carbonnode.isVerbose && orig.groupEnd(), superLogger('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 = origionalWindowLocation;
4293
+ window.location = originalWindowLocation;
4294
4294
  fs.writeFileSync(validSqlFile(), JSON.stringify(validSQL, undefined, 2) ?? '');
4295
4295
  }, 65000);
4296
4296
  }