1.7.6 • Published 1 year ago

@heddendorp/cypress-plugin-multilanguage-coverage v1.7.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

cypress-plugin-multilanguage-coverage

This is a plugin for cypress that allows you to generate a coverage report for your multilanguage project.
Currently, there is support for frontend that runs in the browser and is tested by cypress. For the backend, there is support for java servers that are instrumented with jacoco.

Installation

npm install @heddendorp/cypress-plugin-multilanguage-coverage

You can find the releases of the package on GitHub.

After installing you have to add the following code to your cypress/plugins/index.ts file:

import { registerMultilanguageCoveragePlugin } from 'cypress-plugin-multilanguage-coverage';

registerMultilanguageCoveragePlugin()(on, config);

Usage

Java Instrumentation

You can instrument a java project with jacoco by running the following command in the root of your project:

java -javaagent:.\jars\jacocoagent.jar=output=tcpserver -jar .\jars\your.jar

For Artemis, you can use the following command:

java -javaagent:.\jars\jacocoagent.jar=output=tcpserver -jar .\build\libs\Artemis-6.0.0.jar --spring.profiles.active=dev,jenkins,gitlab,artemis,scheduling,local    

This is for a local setup with GitLab and Jenkins

For that you have to build the project first with

./gradlew spotlessApply -x webapp # to fix formatting issues
./gradlew build -x test -x jacocoTestCoverageVerification # to build the project without running tests

Configuration

You can configure the plugin by passing a config map to the registerMultilanguageCoveragePlugin function. The following options are available:

interface Config {
  /**
   * If enabled, the plugin will generate a JaCoCo coverage report for Java code.
   * @default true
   */
  enableJavaCoverage: boolean;
  /**
   * If enabled, the java coverage will be reset when the browser is launched.
   * @default true
   */
  resetCoverageOnSpecStart: boolean;
  /**
   * The path where JaCoCo files will be written to.
   * @default 'jacoco'
   */
  jaCoCoFilePath: string;
  /**
   * The path where the compiled frontend files are located.
   * @default '../../../build/resources/main/static'
   */
  frontendBuildLocation: string;
  /**
   * The path where the coverage report will be written to.
   * @default 'coverage'
   */
  coverageFolder: string;
  /**
   * Base path for this plugin.
   * @default __dirname
   */
  workingDirectory: string;
  /**
   * The path where the compiled Java classes are located.
   * @default '../../../build/classes'
   */
  javaClassesLocation: string;
  /**
   * The path where the Java source files are located.
   * @default '../../../src/main/java'
   */
  javaSourceLocation: string;
  /**
   * If enabled, the raw coverage data will be logged to a file.
   * @default false
   */
  saveRawCoverage: boolean;
  /**
   * If enabled, the coverage report will only be saved if the spec fails.
   * @default true
   */
  onlySaveOnFailure: boolean;
  /**
   * If enabled, the coverage folder will be deleted before the coverage report is generated.
   * @default true
   */
  cleanCoverageFolder: boolean;
  /**
   * The path to the Artemis distribution file.
   * If this is set, the plugin will extract it in place and use the extracted files for coverage.
   * @default '../../../build/libs/Artemis-6.0.0.war'
   */
  distributionFile: string;
}

It is recommended to set the workingDirectory to the root of your cypress project. This way, Your files don't end up in your node_modules folder.

{workingDirectory:path.join(__dirname, '..')}

Limitations

Currently coverage is only collected per file. In future versions of the plugin, more granular coverage could be a feature to support.

References

1.7.3

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.5

1 year ago

1.6.4

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.13

1 year ago

1.4.11

1 year ago

1.4.10

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago