Skip to content

Ability to collect and report coverage in development #414

Open

Description

@krasnoukhov

The use case I had for this is making integration specs (which are using Capybara) collect and report frontend app coverage.

With the current addon approach, it's totally possible to instrument and collect code coverage when running ember server in dev mode (after #413 is merged).

However sendCoverage cannot be imported because it's part of addon-test-support. I'd like to propose for that to be moved to addon so it can be imported. And then users will be able to report coverage no matter the test/dev environment. We're doing it like this so it does not pull dependency into prod:

import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';

if (macroCondition(isDevelopingApp())) {
  let { forceModulesToBeLoaded, sendCoverage } = importSync('ember-cli-code-coverage');

  window.sendCoverage = function () {
    forceModulesToBeLoaded();
    sendCoverage();
  };
}

And then window.sendCoverage() is called on RSpec side. Thoughts?

Activity

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