2

I've set up my package.json to run jest with coverage :

"scripts": {
  "sonar": "node sonar-project.js",
  "test": "jest --coverage",
  "test-analyze": "npm run test && npm run sonar"
},

running npm test will ouput correct lcov.info and lcov-report in HTML format. Standard ouput looks like:

C:\sandbox2\frontend>npm test

> sandbox2-front@0.0.1 test C:\sandbox2\frontend
> jest --coverage

 PASS  test/Converter.spec.ts
  √ Test celsius to Fahrentheit (3 ms)
  √ kelvinToCelcius

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files     |   89.66 |    66.67 |   66.67 |   89.66 | 
 Converter.ts |   89.66 |    66.67 |   66.67 |   89.66 | 21,28-29
--------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.858 s, estimated 1 s
Ran all test suites.

I'm running the (supposedly) same command through Maven with frontend-maven-plugin, with the ad hoc configuration in my pom.xml:

        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
  
            <configuration>
              <workingDirectory>.</workingDirectory>
              <installDirectory>target</installDirectory>
              <npmRegistryURL>https://ci.knowesia.com/npmjs/</npmRegistryURL>
              <nodeVersion>${node.version}</nodeVersion>
            </configuration>
              
              <execution>
                <id>npm-test</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <phase>test</phase>
                <configuration>
                  <arguments>run test</arguments>
                </configuration>
              </execution>

Despite everything looks fine, in the end my coverage reports (lcov.info, converage-final.json) are regenerated but empty.

This can be seen from standard output (you'll notice that no coverage info is displayed here):

[INFO] Running 'npm test --registry=https://internalciurl/npmjs/' in C:\sandbox2\frontend
[INFO]
[INFO] > sandbox2-front@0.0.1 test C:\sandbox2\frontend
[INFO] > jest --coverage
[INFO]
[INFO] PASS test/Converter.spec.ts
[INFO]   â?? Test celsius to Fahrentheit (3 ms)
[INFO]   â?? kelvinToCelcius
[INFO]
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] All files |       0 |        0 |       0 |       0 |
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] Test Suites: 1 passed, 1 total
[INFO] Tests:       2 passed, 2 total
[INFO] Snapshots:   0 total
[INFO] Time:        0.94 s, estimated 1 s
[INFO] Ran all test suites.

Are there any specific configuration to do? Is it an issue in the frontend-maven-plugin?

potame
  • 7,597
  • 4
  • 26
  • 33

0 Answers0