Skip to content

Commit

Permalink
feat: better test reporting using Junit options
Browse files Browse the repository at this point in the history
Changed the options for junit reporting to better organise the tests.
Tests will now be displayed in Gitlab with the top-level describe, test name, and file path.
  • Loading branch information
emmacasolin committed Jun 29, 2022
1 parent d6b3a64 commit 9bba1e4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 44 deletions.
14 changes: 6 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ build:build-generate:
- ./tmp/build-pipelines.yml
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Manually run on commits other than master and staging and ignore version commits
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:platforms:
stage: build
Expand All @@ -169,10 +168,9 @@ build:platforms:
strategy: depend
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Manually run on commits other than master and staging and ignore version commits
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:prerelease:
stage: build
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ module.exports = {
},
reporters: [
'default',
['jest-junit', { outputDirectory: '<rootDir>/tmp/junit' }],
['jest-junit', {
outputDirectory: '<rootDir>/tmp/junit',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
addFileAttribute: 'true',
}],
],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', '!src/**/*.d.ts'],
coverageReporters: ['text', 'cobertura'],
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.1",
"jest-junit": "^13.2.0",
"jest-junit": "^14.0.0",
"jest-mock-process": "^1.4.0",
"pkg": "5.6.0",
"prettier": "^2.6.2",
Expand Down
6 changes: 3 additions & 3 deletions scripts/build-pipelines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ build:linux:
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
EOF
Expand Down Expand Up @@ -103,7 +103,7 @@ build:windows:
- ./tmp/junit/junit.xml
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
EOF
Expand Down Expand Up @@ -138,7 +138,7 @@ build:macos:
- ./tmp/junit/junit.xml
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
EOF
Expand Down
24 changes: 0 additions & 24 deletions tests/testSequencer.ts

This file was deleted.

0 comments on commit 9bba1e4

Please sign in to comment.