ember-cli-code-coverage icon indicating copy to clipboard operation
ember-cli-code-coverage copied to clipboard

Update README to callout existing issue with test coverage not being generated when running in CI

Open cah-john-ryan opened this issue 5 months ago • 0 comments

From: https://github.com/ember-cli-code-coverage/ember-cli-code-coverage/issues/420#issuecomment-2332270042

In reviewing comments from @kategengler here https://github.com/ember-cli-code-coverage/ember-cli-code-coverage/issues/380#issuecomment-1793077046, I have experimented and found the below interim solution.


The README should reflect the below interim solution while this issue is present.

Add the below line as a new property in the APP object of the file config/environment.js:

APP: {
    isRunningWithServerArgs: process.argv.includes('--server') || process.argv.includes('-s')
}

In the existing file tests/test-helper.js, replace the block of code:

import { forceModulesToBeLoaded, sendCoverage } from 'ember-cli-code-coverage/test-support';
import Qunit from 'qunit';

QUnit.done(async function() {
  forceModulesToBeLoaded();
  await sendCoverage();
});

with instead:

import { forceModulesToBeLoaded, sendCoverage } from 'ember-cli-code-coverage/test-support';
import Qunit from 'qunit';

if (config.APP.isRunningWithServerArgs) {
  // until Testem is patched, this will fail to POST coverage in CI mode (running tests with -s or --server as an argument)
  // Ref: https://github.com/testem/testem/issues/1577
  QUnit.done(async function () {
    forceModulesToBeLoaded();
    await sendCoverage();
  });
} else {
  //eslint-disable-next-line no-undef
  Testem.afterTests(function (config, data, callback) {
    forceModulesToBeLoaded();
    sendCoverage(callback);
  });
}

cah-john-ryan avatar Sep 05 '24 17:09 cah-john-ryan