codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 723 forks source link

Failing to convert test coverage jsons to istanbul format #3642

Closed BugrahanDurukan closed 7 months ago

BugrahanDurukan commented 1 year ago

What are you trying to achieve?

I am trying to get the code coverage for my project which I keep my e2eTest project within. I am going according to the documentation: capturing code coverage. After I run all of the test with the plugin enabled, I get the json files in the output/coverage folder.

What do you get instead?

However, when I use the code piece for converting coverage to istanbul formate, I get this error

image

I guess the converter expects the system files to be in my e2eTest project. What am I doing wrong? Is there a healthy way to change the expected path for this?

Also, we decided that those files that I mentioned above are unneeded files so I tried to exclude those files by change the regex for the file variable to point to "module" folder's files.

image

But when I do that I get this error:

image

which means I capture nothing with my regex.

Here is what my file system looks like after the running coverage with the unneeded files and after running npx nyc report --reporter html -t coverage

image

as you can see there is only one subhtml created

Details

# paste config here
/** @type {CodeceptJS.MainConfig} */
const { exec } = require("child_process");
exports.config = {
  tests: "./tests/*_test.js",
  output: "./output",
  helpers: {
    Playwright: {
      url: "http://localhost:3002/#!",
      show: true,
      browser: "chromium",
    },
    LocatorOperationsHelper: {
      require: "./locatoroperations_helper.js",
    },
    MobileOperations: {
      require: "./mobileoperations_helper.js",
    },
    FileSystem: {},
  },
  plugins: {
    subtitles: {
      enabled: true,
    },
    pauseOnFail: {},
    tryTo: {
      enabled: true,
    },
    coverage: {
      enabled: true,
    },
  },
  async bootstrap() {
    exec("node ../e2e/reset-db.js");
  },

  include: {
    I: "./steps_file.js",
    LoginPage: "./pages/LoginPage.js",
    NavbarFragment: "./fragments/NavbarFragment.js",
    AddUserPage: "./pages/AddUserPage.js",
    UserListPage: "./pages/UserListPage.js",
    LdapAddUserPage: "./pages/LdapAddUserPage.js",
    LdapSettingsPage: "./pages/LdapSettingsPage.js",
    CsvAddUserPage: "./pages/CsvAddUserPage.js",
    GroupsPage: "./pages/GroupsPage.js",
    EditUserPage: "./pages/EditUserPage.js",
    AddRolePage: "./pages/AddRolePage.js",
    ChangePasswordPage: "./pages/ChangePasswordPage.js",
    EditProfilePage: "./pages/EditProfilePage.js",
    RoleListPage: "./pages/RoleListPage.js",
    DevicesPage: "./pages/DevicesPage.js",
    PoliciesPage: "./pages/PoliciesPage.js",
    ApnPage: "./pages/ApnPage.js",
    ExchangeConfigurationsPage: "./pages/ExchangeConfigurationsPage.js",
    KioskPage: "./pages/KioskPage.js",
    HomeScreenLayoutsPage: "./pages/HomeScreenLayoutsPage.js",
    WifiConfigurationsPage: "./pages/WifiConfigurationsPage.js",
    KeyguardFeaturesPage: "./pages/KeyguardFeaturesPage.js",
    PermissionGrantStatesPage: "./pages/PermissionGrantStatesPage.js",
    WebContentFiltersPage: "./pages/WebContentFiltersPage.js",
    PasscodePoliciesPage: "./pages/PasscodePoliciesPage.js",
    SingleAppModesPage: "./pages/SingleAppModesPage.js",
    WallpapersPage: "./pages/WallpapersPage.js",
    VpnConfigurationsPage: "./pages/VpnConfigurationsPage.js",
    SharedDeviceConfigurationsPage: "./pages/SharedDeviceConfigurationsPage.js",
    SystemUpdatePoliciesPage: "./pages/SystemUpdatePoliciesPage.js",
    IosAccountsPage: "./pages/IosAccountsPage.js",
    IosAppNotificationSettingsPage: "./pages/IosAppNotificationSettingsPage.js",
    FirewallRulesPage: "./pages/FirewallRulesPage.js",
    PredefinedAppsPage: "./pages/PredefinedAppsPage.js",
    CallBlacklistsPage: "./pages/CallBlacklistsPage.js",
    MyLocationsPage: "./pages/MyLocationsPage.js",
    CriteriaPage: "./pages/CriteriaPage.js",
    ApplicationsPage: "./pages/ApplicationsPage.js",
    BooksPage: "./pages/BooksPage.js",
    GeneralDeviceConfigPage: "./pages/GeneralDeviceConfigPage.js",
    AssignPoliciesPage: "./pages/AssignPoliciesPage.js",
    LicenseInfoPage: "./pages/LicenseInfoPage.js",
    AppleConfiguratorProfilesPage: "./pages/AppleConfiguratorProfilesPage.js",
    CertificatesPage: "./pages/CertificatesPage.js",
    DeviceFilePage: "./pages/DeviceFilePage.js",
    ProxyConfigurationPage: "./pages/ProxyConfigurationPage.js",
    CommandsPage: "./pages/CommandsPage.js",
    SecureExchangeSettingsPage: "./pages/SecureExchangeSettingsPage.js",
    CloudConnectPage: "./pages/CloudConnectPage.js",
    KibanaDashboardsPage: "./pages/KibanaDashboardsPage.js",
    UserSpecificVpnPage: "./pages/UserSpecificVpnPage.js",
    UpdateMdmAgentsPage: "./pages/UpdateMdmAgentsPage.js",
    SimCardNumbersPage: "./pages/SimCardNumbersPage.js",
    SystemSettingsPage: "./pages/SystemSettingsPage.js",
    LandingDashboardPage: "./pages/LandingDashboardPage.js",
  },
  name: "e2eTest",
};
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity.

cenfun commented 7 months ago

I can't help fix the issue, but introduce a simple plugin to generate coverage reports for codeceptjs: https://github.com/cenfun/codeceptjs-monocart-coverage

kobenguyent commented 7 months ago

thanks @cenfun for your solution, we decided to fix the issue using yours. 🎉