diff --git a/.github/workflows/CI-pipeline.yml b/.github/workflows/CI-pipeline.yml index a979f2c..3f16d56 100644 --- a/.github/workflows/CI-pipeline.yml +++ b/.github/workflows/CI-pipeline.yml @@ -28,9 +28,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 - name: Install of node dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5575f24..d61f3c7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,9 +22,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 - name: Install of node dependencies @@ -41,9 +41,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://registry.npmjs.org' @@ -59,7 +59,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://npm.pkg.github.com' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3d55a2..4a84d23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Read version id: readVersion run: | @@ -78,9 +78,9 @@ jobs: versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup NodeJS - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: '12' - name: Configure git @@ -139,7 +139,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Create Release id: createRelease uses: actions/create-release@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f490c2..d6ae066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ +### Changed +- `@reportportal/client-javascript` bumped to version `5.1.3`, new `launchUuidPrintOutput` types introduced: 'FILE', 'ENVIRONMENT'. ## [5.1.7] - 2024-02-21 -## Changed +### Changed - `@reportportal/client-javascript` bumped to version `5.1.2`. +### Fixed +- Setting step id in case of existing one, thanks to [noacohen1](https://github.com/noacohen1). ## [5.1.6] - 2023-12-19 ### Fixed @@ -16,7 +20,7 @@ - `@reportportal/client-javascript` bumped to version `5.0.15`. Logging link to the launch on its finish now available by default. ## [5.1.4] - 2023-10-05 -## Changed +### Changed - `@reportportal/client-javascript` bumped to version `5.0.14`. ## [5.1.3] - 2023-09-07 diff --git a/README.md b/README.md index dc9f1ac..41a0d97 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ The full list of available options presented below. | launchId | Optional | Not set | The _ID_ of an already existing launch. The launch must be in 'IN_PROGRESS' status while the tests are running. Please note that if this _ID_ is provided, the launch will not be finished at the end of the run and must be finished separately. | | restClientConfig | Optional | Not set | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests).
Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. | | launchUuidPrint | Optional | false | Whether to print the current launch UUID. | -| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`. | +| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR', 'FILE', 'ENVIRONMENT'. Works only if `launchUuidPrint` set to `true`. File format: `rp-launch-uuid-${launch_uuid}.tmp`. Env variable: `RP_LAUNCH_UUID`. | | includeTestSteps | Optional | false | Allows you to see the test steps at the log level. | | includePlaywrightProjectNameToCodeReference | Optional | false | Includes Playwright project name to code reference. See [`testCaseId and codeRef calculation`](#setTestCaseId). It may be useful when you want to see the different history for the same test cases within different playwright projects. | | extendTestDescriptionWithLastError | Optional | true | If set to `true` the latest error log will be attached to the test case description. | diff --git a/VERSION b/VERSION index cbad66a..72675d9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.1.7 +5.1.8-SNAPSHOT diff --git a/package-lock.json b/package-lock.json index 9a01ae3..ae117b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,10 @@ "packages": { "": { "name": "@reportportal/agent-js-playwright", - "version": "5.1.6", + "version": "5.1.7", "license": "Apache-2.0", "dependencies": { - "@reportportal/client-javascript": "^5.1.2", + "@reportportal/client-javascript": "^5.1.3", "strip-ansi": "6.0.1" }, "devDependencies": { @@ -18,7 +18,7 @@ "@types/node": "^18.14.2", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", - "axios": "^0.27.2", + "axios": "^0.28.1", "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-typescript": "^14.0.2", @@ -1344,13 +1344,13 @@ } }, "node_modules/@reportportal/client-javascript": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@reportportal/client-javascript/-/client-javascript-5.1.2.tgz", - "integrity": "sha512-Tjl1Cp0Cc5JFXzOI4sNLORvDh5leVHp7SSLqJGo7o/6jEFWlFDsdjOrtby5SGUpAw5Wq0eKuP3DQId4Xv5zADw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/@reportportal/client-javascript/-/client-javascript-5.1.3.tgz", + "integrity": "sha512-1/utoKnHUgiilR6Ep8pHvuNZGv5oDeI+x1/aJNu8IADoVG1U0Q4tB2trWHDIY07T/PCzrnzp6dVcCu/wLsdVRA==", "dependencies": { - "axios": "^1.6.5", - "axios-retry": "^4.0.0", - "glob": "^7.2.3", + "axios": "^1.6.8", + "axios-retry": "^4.1.0", + "glob": "^8.1.0", "ini": "^2.0.0", "uniqid": "^5.4.0", "uuid": "^9.0.1" @@ -1360,15 +1360,52 @@ } }, "node_modules/@reportportal/client-javascript/node_modules/axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", "dependencies": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } }, + "node_modules/@reportportal/client-javascript/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -1938,18 +1975,19 @@ } }, "node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.28.1.tgz", + "integrity": "sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ==", "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "node_modules/axios-retry": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.0.0.tgz", - "integrity": "sha512-F6P4HVGITD/v4z9Lw2mIA24IabTajvpDZmKa6zq/gGwn57wN5j1P3uWrAV0+diqnW6kTM2fTqmWNfgYWGmMuiA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.1.0.tgz", + "integrity": "sha512-svdth4H00yhlsjBbjfLQ/sMLkXqeLxhiFC1nE1JtkN/CIssGxqk0UwTEdrVjwA2gr3yJkAulwvDSIm4z4HyPvg==", "dependencies": { "is-retry-allowed": "^2.2.0" }, @@ -2082,6 +2120,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2318,7 +2357,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/confusing-browser-globals": { "version": "1.0.11", @@ -3311,9 +3351,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -3486,6 +3526,7 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -4995,6 +5036,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -5286,6 +5328,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "engines": { "node": ">=0.10.0" } diff --git a/package.json b/package.json index 95c4885..f7f17bd 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test:coverage": "jest --coverage" }, "dependencies": { - "@reportportal/client-javascript": "^5.1.2", + "@reportportal/client-javascript": "^5.1.3", "strip-ansi": "6.0.1" }, "files": [ @@ -25,7 +25,7 @@ "@types/node": "^18.14.2", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", - "axios": "^0.27.2", + "axios": "^0.28.1", "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-typescript": "^14.0.2", diff --git a/src/__tests__/utils.spec.ts b/src/__tests__/utils.spec.ts index 72addaf..7b3ba34 100644 --- a/src/__tests__/utils.spec.ts +++ b/src/__tests__/utils.spec.ts @@ -26,6 +26,7 @@ import { isFalse, getAttachments, isErrorLog, + fileExists, calculateRpStatus, } from '../utils'; import fs from 'fs'; @@ -56,6 +57,23 @@ describe('testing utils', () => { }); }); + describe('fileExists', () => { + test('should return true', async () => { + jest.spyOn(fs.promises, 'stat').mockImplementationOnce(() => Promise.resolve({} as fs.Stats)); + + const existingFilePath = 'existing-file-path'; + const isFileExist = await fileExists(existingFilePath); + + expect(isFileExist).toBe(true); + }); + test('should return false', async () => { + const notExistingFilePath = 'not-existing-file-path'; + const isFileExist = await fileExists(notExistingFilePath); + + expect(isFileExist).toBe(false); + }); + }); + describe('promiseErrorHandler', () => { let spyConsoleError: jest.SpyInstance; beforeEach(() => { @@ -242,7 +260,7 @@ describe('testing utils', () => { const file1Data = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); const file2Data = Buffer.from([1, 2, 3, 4, 5, 6, 7]); - jest.spyOn(fs, 'existsSync').mockImplementationOnce((): boolean => true); + jest.spyOn(fs.promises, 'stat').mockImplementationOnce(() => Promise.resolve({} as fs.Stats)); jest.spyOn(fs.promises, 'readFile').mockImplementationOnce(async () => file1Data); diff --git a/src/utils.ts b/src/utils.ts index 1a29c85..c80acc5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -92,6 +92,20 @@ export const sendEventToReporter = (type: string, data: any, suite?: string): vo process.stdout.write(JSON.stringify({ type, data, suite })); }; +export const fileExists = async (filePath: string) => { + try { + await fsPromises.stat(filePath); + return true; + } catch (error) { + // ENOENT code - File does not exist + if (error.code === 'ENOENT') { + return false; + } else { + throw error; + } + } +}; + export const getAttachments = async ( attachments: TestResult['attachments'], { uploadTrace, uploadVideo }: AttachmentsConfig = { uploadTrace: true, uploadVideo: true }, @@ -122,7 +136,8 @@ export const getAttachments = async ( if (body) { fileContent = body; } else { - if (!fs.existsSync(attachmentPath)) { + const isFileExist = await fileExists(attachmentPath); + if (!isFileExist) { return; } fileContent = await fsPromises.readFile(attachmentPath);