feathers icon indicating copy to clipboard operation
feathers copied to clipboard

mocha tests terminating before after/afterEach finishes

Open ewah opened this issue 10 months ago • 2 comments

because the package.json mocha script has to be run with --exit

for the last test/test suite after() and afterEach() are prematurely terminated and never finish

ewah avatar Mar 14 '25 18:03 ewah

unfortunately i'm getting around this by creating a test file test/z/z.test.js. (the funny names are for -g [name] flag)

describe('sleep, so asyncs can finish', () => {
  const sleep = (ms) => {
    return new Promise((resolve) => setTimeout(resolve, ms));
  };

  let alreadySlept = false;

  it('MINIMUM sleep 2s', async function () {
    if (alreadySlept) return;
    this.timeout(3000);
    await sleep(2000);
    alreadySlept = true;
  });

  it('BASIC sleep 2s', async function () {
    if (alreadySlept) return;
    this.timeout(3000);
    await sleep(2000);
    alreadySlept = true;
  });

  it('INTEGRATION sleep 2s', async function () {
    if (alreadySlept) return;
    this.timeout(3000);
    await sleep(2000);
    alreadySlept = true;
  });
});

ewah avatar Mar 14 '25 18:03 ewah

You can update the test configuration to your needs - e.g. by removing the --exit.

daffl avatar Sep 09 '25 21:09 daffl