npm test无法检测到jenkins中的新测试文件更改 [英] npm test does not detect new test file changes in jenkins

查看:364
本文介绍了npm test无法检测到jenkins中的新测试文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins/jest和CI,

Jenkins/jest and CI ,

我已经使用create-react-app创建了一个React APP,并且使用JEST进行了测试,并且我在一个创建的app.test.js文件中做了一些新的更改,并承诺git-hub-与jenkins挂钩-当我在本地计算机上运行npm test,测试运行正常,并且都通过.. 但是,当我运行詹金斯管道脚本时,它显示以下内容:

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.

我尝试更改app.test.js-创建了一个新的文件提交更改,然后在jenkins中创建了一个新管道,然后再次尝试了(我也尝试过这里讨论的内容:

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!

推荐答案

由于Jenkins在Windows上运行,因此测试未在jenkins上运行,并且Windows不支持glob,即src/**/*.js.

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

在基于Linux操作系统安装的Jenkins上构建项目时未遇到此问题!

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

这篇关于npm test无法检测到jenkins中的新测试文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆