<commit_before>const { outputBanner } = require('ci-utils');
const sauce = require('./scripts/nightwatch-sauce');

const theGlobals = {
  testingUrl: 'https://boltdesignsystem.com',
  results: [],
  testCount: 0,

  afterEach(browser, cb) {
    theGlobals.testCount += 1;
    outputBanner(`global afterEach called, testCount at ${testCount}`);
    sauce(browser, cb);
  },

  reporter(results, cb) {
    // totalReports += 1;
    console.log(`global reporter called`);
    console.log(results);
    cb();
  },
};

module.exports = theGlobals;
<commit_msg>storing nightwatch result data in filesystem<commit_after>const { outputBanner } = require('ci-utils');
const { tmpdir } = require('os');
const { join } = require('path');
const { readFileSync, writeFileSync } = require('fs');
const sauce = require('./scripts/nightwatch-sauce');

const dataFilePath = join(tmpdir, 'nightwatch-results.json');
const read = () => JSON.parse(readFileSync(dataFilePath, 'utf8'));
const write = data => writeFileSync(dataFilePath, JSON.stringify(data), 'utf8');

console.log({ dataFilePath });

write({
  testCount: 0,
  results: [],
});

const theGlobals = {
  testingUrl: 'https://boltdesignsystem.com',
  results: [],
  testCount: 0,

  afterEach(browser, cb) {
    const data = read();
    data.testCount += 1;
    write(data);
    // theGlobals.testCount += 1;
    outputBanner(`global afterEach called, testCount at ${data.testCount}`);
    sauce(browser, cb);
  },

  reporter(results, cb) {
    // totalReports += 1;
    const data = read();
    data.results.push(results);
    write(data);
    console.log(`global reporter called; have total of ${data.results.length}`);
    console.log(results);
    cb();
  },
};

module.exports = theGlobals;

{'fraction_non_alphanumeric': 0.1668584579976985, 'fraction_numerical': 0.005753739930955121, 'mean_word_length': 4.099706744868035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2933020', 'n_tokens_mistral': 569, 'n_tokens_neox': 567, 'n_words': 122}