npm test does not detect new test file changes in jenkins

旧时模样 提交于 2020-01-04 14:19:35

问题


Jenkins/jest and CI ,

I have created a react APP using create-react-app and I use JEST for testing and I did some new changes in a file created app.test.js and committed to git-hub- hooked it with jenkins -when I run npm test in the local machine the tests are run fine and they all pass .. BUT when i run the jenkins pipeline script it says the following :

No tests found related to files changed since last commit.
Press a to run all tests, or run Jest with --watchAll.

Watch Usage
› Press a to run all tests.
› Press p to filter by a filename regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.

I have tried changing app.test.js -created a new file commit changes and then created a new pipeline in jenkins and tried again ( I have also tried these discussed here :https://github.com/facebookincubator/create-react-app/issues/930) but I still get the above error : my pipeline script is shown below:

   node{
        stage "CI"    
        git 'https://github.com/NaveenDK/mentalshortcuts.git' 
        bat "npm install"  
        stage " Unit testing" 
        bat "npm test" 
    }
        def notify(status){
        emailext (
          to: "dd@dd.com",
          subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
          body: """<p>${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
            <p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
        )

    }

    node {
        notify("Deploy to staging?")
    }
    input 'Deploy to Staging?'


    node {
        bat "npm run-script build"
    }

Any help any links anything at all would be great!


回答1:


The tests did not run on jenkins as Jenkins was running on Windows, and Windows doesn't support glob, which is src/**/*.js.

this problem was not encountered when the project was build on Jenkins that was installed on a Linux OS!




回答2:


I encounter this problem on my local machine like this,

"test": "jest --watchAll"


来源:https://stackoverflow.com/questions/46986695/npm-test-does-not-detect-new-test-file-changes-in-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!