How to run Jest tests on Jenkins Server

2019-03-27 12:00发布

I'm attempting to run my Jest Test during Jenkins deployment. If I ssh into the server, I can sudo into the Jenkins user and successfully run the tests from the workspace. However, I get an error when I attempt to build the project from the GUI. Here is my project setup:

I have installed the nodejs plugin, which in turn installs gulp, jest-cli and babel globally. enter image description here

Then in build steps:

enter image description here

The test fails with this error:

TypeError: Cannot read property 'getResourceByPath' of null
    at Loader.getDependenciesFromPath (/var/lib/jenkins/workspace/PHPStaging/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:570:39)
    at /var/lib/jenkins/workspace/PHPStaging/node_modules/jest-cli/src/TestRunner.js:250:22
    at process._tickCallback (node.js:368:9)
Running 6 test suites...
 FAIL  resources/__tests__/myTest.js

It appears that Node is having trouble requiring modules from the tests, but I'm not totally sure. Any help or direction would be appreciated.

0条回答
登录 后发表回答