diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eef524..34a5be2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,5 +41,25 @@ jobs: - name: Run tests run: npm run test + - name: Python setup + if: always() + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: TestRail CLI upload results + if: always() + run: | + pip install trcli + trcli -y \ + -h "https://$TR_INSTANCE.testrail.io" \ + --project "TR_PROJECT_NAME" \ + -u TR_USER_EMAIL \ + -p TR_PASSWORD \ + parse_junit \ + --title "Automated Tests - $GITHUB_REF_NAME" \ + --run-description ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \ + -f "junit-report.xml" + - name: Run audit run: npm audit diff --git a/.gitignore b/.gitignore index 1e1ecf4..271a844 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ dist .vscode .idea build/ -processor/.env \ No newline at end of file +processor/.env +processor/junit-report.xml \ No newline at end of file diff --git a/processor/jest.config.cjs b/processor/jest.config.cjs index 5888667..108d1c2 100644 --- a/processor/jest.config.cjs +++ b/processor/jest.config.cjs @@ -1,5 +1,5 @@ module.exports = { - displayName: 'Tests Typescript Application - shopmacher-mollie-processor', + displayName: 'Tests Mollie connector - shopmacher-mollie-connector', moduleDirectories: ['node_modules', 'src'], testMatch: ['**/tests/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'], preset: 'ts-jest', @@ -7,4 +7,5 @@ module.exports = { setupFiles: ['/src/jest.setup.ts'], setupFilesAfterEnv: ['/src/jest.setupAfterEnv.ts'], modulePathIgnorePatterns: ['/src/jest.setup.ts'], + reporters: ['default', 'jest-junit'] }; diff --git a/processor/junitTestCaseProperties.js b/processor/junitTestCaseProperties.js new file mode 100644 index 0000000..9eff4c8 --- /dev/null +++ b/processor/junitTestCaseProperties.js @@ -0,0 +1,5 @@ +module.exports = (testResult) => { + return { + testrail_case_field: `custom_tags:["1"]`, + }; +}; diff --git a/processor/package-lock.json b/processor/package-lock.json index b26dbef..de27807 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "0.0.12", + "version": "0.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "0.0.12", + "version": "0.0.13", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -31,6 +31,7 @@ "eslint-plugin-prettier": "5.1.3", "@typescript-eslint/parser": "7.13.1", "eslint-config-prettier": "9.1.0", + "jest-junit": "^16.0.0", "@types/validator": "^13.12.0", "jest": "^29.7.0", "ts-jest": "^29.1.5", @@ -2757,6 +2758,18 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", @@ -4434,6 +4447,15 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-junit/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -6456,6 +6478,21 @@ "node": ">=4" } }, + "node_modules/jest-junit": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-16.0.0.tgz", + "integrity": "sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==", + "dev": true, + "dependencies": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^8.3.2", + "xml": "^1.0.1" + }, + "engines": { + "node": ">=10.12.0" + } + }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -8561,6 +8598,12 @@ "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", "dev": true }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", diff --git a/processor/package.json b/processor/package.json index e70f207..c757fa9 100644 --- a/processor/package.json +++ b/processor/package.json @@ -13,7 +13,7 @@ "lint": "eslint . --ext .ts", "prettier": "prettier --write '**/*.{js,ts}'", "prettier:check": "prettier --check '**/*.{js,ts}'", - "test": "jest --detectOpenHandles --clearMocks --colors --config jest.config.cjs", + "test": "jest --detectOpenHandles --clearMocks --colors --config jest.config.cjs --ci --ci --reporters=default --reporters=jest-junit", "test:watch": "jest --watch --clearMocks --detectOpenHandles --colors --config jest.config.cjs", "preinstall": "npx npm-force-resolutions", "connector:post-deploy": "node dist/connector/post-deploy.js", @@ -51,6 +51,7 @@ "eslint-plugin-prettier": "5.1.3", "eslint-plugin-unused-imports": "3.2.0", "jest": "^29.7.0", + "jest-junit": "^16.0.0", "ngrok": "^5.0.0-beta.2", "nodemon": "^3.1.4", "npm-force-resolutions": "^0.0.10", @@ -72,5 +73,15 @@ "proxy-from-env": "^1.1.0", "uuid": "^10.0.0", "validator": "^13.12.0" + }, + "jest-junit": { + "suiteName": "jest tests", + "outputDirectory": ".", + "outputName": "junit-report.xml", + "uniqueOutputName": "false", + "classNameTemplate": "{classname}", + "titleTemplate": "{classname}-{title}", + "ancestorSeparator": " › ", + "usePathForSuiteName": "true" } } diff --git a/processor/tests/validators/env.validators.spec.ts b/processor/tests/validators/env.validators.spec.ts index 11a37fa..ed4ed34 100644 --- a/processor/tests/validators/env.validators.spec.ts +++ b/processor/tests/validators/env.validators.spec.ts @@ -100,7 +100,7 @@ describe('Test env.validators.ts', () => { condition: { min: 1, max: undefined }, }, ])( - 'should return the correct validation array expected envValidators[%s][%s] contains [%s, %s]', + 'should return the correct validation array contains [%s, %s]', async ({ index1, index2, field1, field2, error, condition }) => { field1 && expect(envValidators[index1][index2]).toContain(field1); field2 && expect(envValidators[index1][index2]).toContain(field2);