OneDev is an open source GitLab-like devops platform emphasizing easy-of-use. Jest is a popular javascript testing framework. This tutorial explains how to set up OneDev to publish Jest test report in a CI process.
Run OneDev
Run below command in your terminal on Linux/Mac to start OneDev:
$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/onedev:/opt/onedev -p 6610:6610 -p 6611:6611 1dev/server:4.3.3
Then point your browser to http://localhost:6610 to set up OneDev following on-screen instructions.
Add a Demo Project
Now add a project in OneDev using Jest test framework, and push the code. For demonstration purpose, letโs use the react project.
-
Create a project in OneDev with name react:
-
Push the code into newly created project:
$ git clone https://github.com/facebook/react $ cd react $ git push http://localhost:6610/react master:master
Run Test and Publish Report
-
Refresh the page after pushing code, and add build spec for the demo project like below:
-
Switch to Edit Source tab to use below source (do not worry about the build spec syntax, you may also use the GUI editor to set up necessary steps and triggers):
version: 6 jobs: - name: CI steps: - !CheckoutStep name: checkout cloneCredential: !DefaultCredential {} condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - !CommandStep name: build image: node:10.16-alpine commands: - export CI=true - 'yarn install ' - yarn test --json --outputFile=testResults.json condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - !PublishJestTestReportStep name: publish test report reportName: Jest Test Report filePatterns: testResults.json condition: ALWAYS triggers: - !BranchUpdateTrigger {} retryCondition: never maxRetries: 3 retryDelay: 30 cpuRequirement: 250m memoryRequirement: 128m timeout: 3600
After build spec is committed, OneDev will run the job automatically. Note that Jest runs slowly on Docker on Mac. The build may take 30~60 minutes to complete. Visit the online demo page to see the report in action if you do not want to wait.
Access Jest Report
After build is finished, the Jest test report will be available in build detail page. Here we can filter tests by status and file path, view test trends by day, or jump to error position in file.
Top comments (0)