Generator-jhipster: Ci-Cd Jenkins - Frontend tests finally stage does not work : No result on reports !

Created on 4 Jul 2018  路  19Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

Tested on jHipster 5.0.1, on a fresh install and a freshly generated Jenkinfiles.
The "Frontend tests" crashes on Jenkins with the following error :
ERROR: Aucun des rapports de test ne contient de r茅sultat

Jenkinsfile :

    stage('frontend tests') {
        try {
            bat "mvnw com.github.eirslett:frontend-maven-plugin:yarn -Dfrontend.yarn.arguments=test"
        } catch(err) {
            throw err
        } finally {
            junit '**/target/test-results/jest/TESTS-*.xml'
        }
    }

(Note that I'm on Windows....)

target\test-results\jest\TESTS-results.xml on my workspace :

<?xml version="1.0" encoding="UTF-8"?>
<testExecutions version="1">
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\shared\login\login.component.spec.ts">
    <testCase name="Component Tests LoginComponent should authenticate the user upon login when previous state was set" duration="123"/>
    <testCase name="Component Tests LoginComponent should authenticate the user upon login when previous state was not set" duration="26"/>
    <testCase name="Component Tests LoginComponent should empty the credentials upon cancel" duration="25"/>
    <testCase name="Component Tests LoginComponent should redirect user when register" duration="21"/>
    <testCase name="Component Tests LoginComponent should redirect user when request password" duration="26"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\health\health.component.spec.ts">
    <testCase name="Component Tests JhiHealthCheckComponent baseName and subSystemName should return the basename when it has no sub system" duration="205"/>
    <testCase name="Component Tests JhiHealthCheckComponent baseName and subSystemName should return the basename when it has sub systems" duration="31"/>
    <testCase name="Component Tests JhiHealthCheckComponent baseName and subSystemName should return the sub system name" duration="18"/>
    <testCase name="Component Tests JhiHealthCheckComponent baseName and subSystemName should return the subsystem when it has multiple keys" duration="17"/>
    <testCase name="Component Tests JhiHealthCheckComponent transformHealthData should flatten empty health data" duration="19"/>
    <testCase name="Component Tests JhiHealthCheckComponent should flatten health data with no subsystems" duration="19"/>
    <testCase name="Component Tests JhiHealthCheckComponent should flatten health data with subsystems at level 1, main system has no additional information" duration="27"/>
    <testCase name="Component Tests JhiHealthCheckComponent should flatten health data with subsystems at level 1, main system has additional information" duration="18"/>
    <testCase name="Component Tests JhiHealthCheckComponent should flatten health data with subsystems at level 1, main system has additional error" duration="15"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\password-reset\finish\password-reset-finish.component.spec.ts">
    <testCase name="Component Tests PasswordResetFinishComponent should define its initial state" duration="36"/>
    <testCase name="Component Tests PasswordResetFinishComponent sets focus after the view has been initialized" duration="24"/>
    <testCase name="Component Tests PasswordResetFinishComponent should ensure the two passwords entered match" duration="37"/>
    <testCase name="Component Tests PasswordResetFinishComponent should update success to OK after resetting password" duration="21"/>
    <testCase name="Component Tests PasswordResetFinishComponent should notify of generic error" duration="19"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\register\register.component.spec.ts">
    <testCase name="Component Tests RegisterComponent should ensure the two passwords entered match" duration="35"/>
    <testCase name="Component Tests RegisterComponent should update success to OK after creating an account" duration="25"/>
    <testCase name="Component Tests RegisterComponent should notify of user existence upon 400/login already in use" duration="27"/>
    <testCase name="Component Tests RegisterComponent should notify of email existence upon 400/email address already in use" duration="16"/>
    <testCase name="Component Tests RegisterComponent should notify of generic error" duration="19"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\audits\audits.component.spec.ts">
    <testCase name="Component Tests AuditsComponent today function  should set toDate to current date" duration="36"/>
    <testCase name="Component Tests AuditsComponent previousMonth function  should set fromDate to current date" duration="30"/>
    <testCase name="Component Tests AuditsComponent By default, on init should set all default values correctly" duration="27"/>
    <testCase name="Component Tests AuditsComponent OnInit Should call load all on init" duration="20"/>
    <testCase name="Component Tests AuditsComponent Create sort object Should sort only by id asc" duration="16"/>
    <testCase name="Component Tests AuditsComponent Create sort object Should sort by timestamp asc then by id" duration="19"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\password-reset\init\password-reset-init.component.spec.ts">
    <testCase name="Component Tests PasswordResetInitComponent should define its initial state" duration="29"/>
    <testCase name="Component Tests PasswordResetInitComponent sets focus after the view has been initialized" duration="22"/>
    <testCase name="Component Tests PasswordResetInitComponent notifies of success upon successful requestReset" duration="16"/>
    <testCase name="Component Tests PasswordResetInitComponent notifies of unknown email upon email address not registered/400" duration="17"/>
    <testCase name="Component Tests PasswordResetInitComponent notifies of error upon error response" duration="27"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\user-management\user-management-update.component.spec.ts">
    <testCase name="Component Tests User Management Update Component OnInit Should load authorities and language on init" duration="161"/>
    <testCase name="Component Tests User Management Update Component save Should call update service on save for existing user" duration="28"/>
    <testCase name="Component Tests User Management Update Component save Should call create service on save for new user" duration="21"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\password\password.component.spec.ts">
    <testCase name="Component Tests PasswordComponent should show error if passwords do not match" duration="31"/>
    <testCase name="Component Tests PasswordComponent should call Auth.changePassword when passwords match" duration="24"/>
    <testCase name="Component Tests PasswordComponent should set success to OK upon success" duration="25"/>
    <testCase name="Component Tests PasswordComponent should notify of error if change password fails" duration="17"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\activate\activate.component.spec.ts">
    <testCase name="Component Tests ActivateComponent calls activate.get with the key from params" duration="31"/>
    <testCase name="Component Tests ActivateComponent should set set success to OK upon successful activation" duration="22"/>
    <testCase name="Component Tests ActivateComponent should set set error to ERROR upon activation failure" duration="21"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\settings\settings.component.spec.ts">
    <testCase name="Component Tests SettingsComponent should send the current identity upon save" duration="36"/>
    <testCase name="Component Tests SettingsComponent should notify of success upon successful save" duration="30"/>
    <testCase name="Component Tests SettingsComponent should notify of error upon failed save" duration="18"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\user-management\user-management.component.spec.ts">
    <testCase name="Component Tests User Management Component OnInit Should call load all on init" duration="44"/>
    <testCase name="Component Tests User Management Component setActive Should update user and call load all" duration="25"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\user-management\user-management-detail.component.spec.ts">
    <testCase name="Component Tests User Management Detail Component OnInit Should call load all on init" duration="32"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\core\user\user.service.spec.ts">
    <testCase name="Service Tests User Service Service methods should call correct URL" duration="21"/>
    <testCase name="Service Tests User Service Service methods should return User" duration="15"/>
    <testCase name="Service Tests User Service Service methods should return Authorities" duration="16"/>
    <testCase name="Service Tests User Service Service methods should propagate not found response" duration="11"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\user-management\user-management-delete-dialog.component.spec.ts">
    <testCase name="Component Tests User Management Delete Component confirmDelete Should call delete service on confirmDelete" duration="32"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\account\password\password-strength-bar.component.spec.ts">
    <testCase name="Component Tests PasswordStrengthBarComponent PasswordStrengthBarComponents should initialize with default values" duration="30"/>
    <testCase name="Component Tests PasswordStrengthBarComponent PasswordStrengthBarComponents should increase strength upon password value change" duration="22"/>
    <testCase name="Component Tests PasswordStrengthBarComponent PasswordStrengthBarComponents should change the color based on strength" duration="24"/>
  </file>
  <file path="C:\Jenkins\Workspace\workspace\Test\src\test\javascript\spec\app\admin\audits\audits.service.spec.ts">
    <testCase name="Service Tests Audits Service Service methods should call correct URL" duration="27"/>
    <testCase name="Service Tests Audits Service Service methods should return Audits" duration="15"/>
    <testCase name="Service Tests Audits Service Service methods should propagate not found response" duration="11"/>
  </file>
</testExecutions> 

End of the execution :

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.391 s
[INFO] Finished at: 2018-07-04T18:48:37+02:00
[INFO] ------------------------------------------------------------------------
[Pipeline] step
Enregistrement des r茅sultats des tests
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Aucun des rapports de test ne contient de r茅sultat
Finished: FAILURE
Motivation for or Use Case
Reproduce the error

Fresh app from jHipster with Jenkinfiles generated by jHipster ci-cd.

Suggest a Fix

Not found yet...

JHipster Version(s)

Tested on 5.0.1 and 5.0.0.

JHipster configuration

Basic app with default config is enough...

Entity configuration(s) entityName.json files generated in the .jhipster directory

None

Browsers and Operating System

My Jenkins is on Windows... Maybe it can help :)

  • [ ] Checking this box is mandatory (this is just to show you read everything)
area

Most helpful comment

I will, it will be a my first in the generator, but let's try, doesn't seem sooo complicated.

All 19 comments

Can you post:

  • the jhipster info
  • the generated Jenkinsfile

The last weeks, I tried to improve the CICD sub gen, so I know I found some issues. I should do a PR as soon as I fixed all of them

And as you are with Windows, not sure this path can work:
junit '**/target/test-results/jest/TESTS-*.xml'

@pascalgrimaud About Windows, I had no problem until when I migrated to Jest. So I guess it's not the problem here.

I'm testing right now and I've just noticed it works with jHipster 5.0.0-beta.3 ! (With Jenkins in Linux this time, not at work right now)

Does not work with 5.0.0-beta.2, 5.0.0 and 5.0.1. I'm testing with Angular 6 everytime.
About Jenkinsfile, I have to adapt it to switch sh to bat and ./mvnw to mvnw. Otherwise, all is the same as generated by jHipster.

If it can help, jHipster 5.0.0-beta.3 has the jest-junit package and configuration, but all other versions hasn't this package. Cannot test anymore right now.

I think I understand the issue. See my comment here:
https://github.com/jhipster/generator-jhipster/issues/7834#issuecomment-399574597

We did the change for Sonar, but maybe broke the results for Jenkins.

So the fix would be to keep both results, and point to the correct folder when using Jenkins and / or Sonar

You're right, it seems you need to keep both format, one for junit and Jenkins, the other for Sonar.

On your comment, the file provided by jest-junit is the same format as the file that karma provides, and it works fine... Completely unable to test right now, maybe I will give a try tomorrow at work.

Yes we modified it for Sonar, I didn't know there was an impact on Jenkins!

@pascalgrimaud, I make it works adding back jest-junit, its config and changing the name of its output file, to not interfere with the one for SonarQube.

One weird thing, with same code, Jenkins shows me a number of tests that changes everybuild... Well...

nice @GuiF007 !
Can you PR plz ?

I will, it will be a my first in the generator, but let's try, doesn't seem sooo complicated.

I make it works adding back jest-junit, its config and changing the name of its output file, to not interfere with the one for SonarQube.

I confirm it fixed the issue. One thing I would change is:

  • use default output with jest-junit: TESTS-results.xml
  • rename the output for Sonar: TESTS-results-sonar.xml (in package.json and in pom.xml)

Perfect, I was wondering how to rename files, things done now, let's work now ;)

PR is done, I cherry-picked one of your commit @pascalgrimaud, upgraded the jest-junit version, changed filenames. I tested and should be OK :)

Hum... It seems my fix doesn't work on Windows... yarn test gives me the following error :

        Failed to write coverage reports:
        ERROR: Error: EEXIST: file already exists, mkdir 'C:\Workspace\MyProject'
        STACK: Error: EEXIST: file already exists, mkdir 'C:\Workspace\MyProject'
    at Object.fs.mkdirSync (fs.js:885:18)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:71:13)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:77:24)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)


Test Suites: 120 passed, 120 total
Tests:       480 passed, 480 total
Snapshots:   0 total
Time:        58.127s
Ran all test suites.
RangeError: Maximum call stack size exceeded
    at normalizeStringWin32 (path.js:33:30)
    at Object.resolve (path.js:328:20)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:68:14)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:77:24)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)
    at sync (C:\Workspace\MyProject\node_modules\mkdirp\index.js:78:17)

If I change jest-conf.js to
[ 'jest-junit', { output: './target/test-results/jest/TESTS-results.xml' } ]
I got both files but still the second error...

let's reopen this ticket, to find a solution

I'm checking with a fresh project from jhipster, maybe it's my specific project that won't work...

Ok it's on my part... Fresh install works properly, sorry for the alert

I'm sooooo stupid, really stupid, tired on this end of week... I copied stupidly the ejs file of jest.conf.ejs... Well, I forgot to replace BUILD_DIR variable... My bad... End of week, deeplyy 馃槤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  路  3Comments

chegola picture chegola  路  4Comments

ahmedeldeeb25 picture ahmedeldeeb25  路  3Comments

RizziCR picture RizziCR  路  3Comments

pascalgrimaud picture pascalgrimaud  路  4Comments