// Generated by bynkc — do not edit by hand.
// top-level test runner

declare const process: { exit(code: number): never; env: { [k: string]: string | undefined } };

import * as test_0 from "./integration_counter_accumulates.test.js";

async function main() {
  const modules = [
    { name: "integration · counter accumulates", run: test_0.run },
  ];
  let passed = 0;
  let failed = 0;
  const PREFIX = "integration \u00b7 ";
  if (process.env.BYNK_TEST_FORMAT === "ndjson") {
    const emit = (o: unknown) => console.log(JSON.stringify(o));
    emit({ type: "run-begin", suites: modules.length });
    for (const m of modules) {
      const integration = m.name.startsWith(PREFIX);
      const suite = integration ? m.name.slice(PREFIX.length) : m.name;
      const kind = integration ? "integration" : "unit";
      const results = await m.run();
      emit({ type: "suite-begin", name: suite, kind, tests: results.length });
      for (const r of results) {
        if (r.pass) {
          passed++;
          emit({ type: "case", suite, name: r.name, outcome: "pass" });
        } else {
          failed++;
          emit({ type: "case", suite, name: r.name, outcome: "fail", message: r.error && r.error.message, location: r.error && r.error.location });
        }
      }
      emit({ type: "suite-end", name: suite });
    }
    emit({ type: "run-end", passed, failed });
  } else {
    console.log("Running tests...\n");
    for (const m of modules) {
      console.log(`${m.name}:`);
      const results = await m.run();
      for (const r of results) {
        if (r.pass) { passed++; console.log(`  \u2713 ${r.name}`); } else { failed++; console.log(`  \u2717 ${r.name}`); if (r.error) console.log(`    ${r.error.message}`); }
      }
      console.log("");
    }
    console.log(`${passed} passed, ${failed} failed.`);
  }
  if (failed > 0) process.exit(1);
}

main();
