Skip to content

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

Open

Description

@cah-john-ryan

From: #420 (comment)

In reviewing comments from @kategengler here #380 (comment), 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);
  });
}

Activity

  1. malatin3 commented on Feb 6, 2025

    @malatin3

    Hello! Possibly a small oversight with this but we noticed that unless you check for test or t you may brick the ability to run tests from visiting /tests while the app is being served.

  2. tniezurawski commented on Feb 9, 2025

    @tniezurawski

    @cah-john-ryan Thank you for the workaround. I run tests in 6 containers and some of them don't save the coverage file 🤷‍♂ I typically get a 50:50 success rate - I mean 3 containers fail, 3 succeeds. I got to the point where I understood that there's no "enough time" to save them but I couldn't figure out why. Now I get it.

    The workaround works great for me ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions