diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..c3af8579 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +lib/ diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 8ae77d37..4d2b8fe3 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -38,4 +38,4 @@ module.exports = { 'no-empty-function': 0, camelcase: 0, }, -} +}; diff --git a/.github/workflows/linter-and-tests.yml b/.github/workflows/linter-and-tests.yml index e210f1f5..1e5f1ae5 100644 --- a/.github/workflows/linter-and-tests.yml +++ b/.github/workflows/linter-and-tests.yml @@ -8,9 +8,9 @@ concurrency: on: push: - branches: [master] + branches: [master, 2.x] pull_request: - branches: [master] + branches: [master, 2.x] jobs: linter-and-tests-on-latest-node: @@ -20,11 +20,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: latest + node-version: 22.x - run: node -v - run: npm ci - run: npm run lint - run: npm run pretty:fix + # - run: npm run test:adapter:playwright:example - run: npm run test - run: npm run test:storage @@ -42,4 +43,4 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm run test - - run: npm run test:storage \ No newline at end of file + - run: npm run test:storage diff --git a/.github/workflows/publish-newman-reporter-to-npm.yml b/.github/workflows/publish-newman-reporter-to-npm.yml index 968a850d..81901b5a 100644 --- a/.github/workflows/publish-newman-reporter-to-npm.yml +++ b/.github/workflows/publish-newman-reporter-to-npm.yml @@ -22,4 +22,4 @@ jobs: - run: npm publish working-directory: ./packages/newman-reporter-testomatio env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.prettierignore b/.prettierignore index 941f8b4f..0a286e73 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,5 @@ lib/template/testomatio.hbs # fails on CI -lib/pipe/testomatio.js \ No newline at end of file +lib/pipe/testomatio.js + +lib/ \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js index c9f98146..3cb0bc5c 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,4 +1,4 @@ -module.exports = { +export default { printWidth: 120, tabWidth: 2, useTabs: false, diff --git a/Changelog.md b/Changelog.md index 7273d456..77303067 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # next + - move the reporter to ESM (except separate libs from `./packages`) - added unit tests for Vitest and Playwright - drop support for Cucumber versions < 7 @@ -8,7 +9,6 @@ - fix all linter issues and enable linter on CI - changed path for Mocha and Jamine import, now its `./lib/adapter/mocha/mocha.cjs` and `./lib/adapter/jasmine/jasmine.cjs` - # 1.1.0 - Rewritten logger and artifacts storage. Test reports contain logs, steps, stack traces. diff --git a/build/scripts/edit-package-json.js b/build/scripts/edit-package-json.js index 60440e34..32d418db 100755 --- a/build/scripts/edit-package-json.js +++ b/build/scripts/edit-package-json.js @@ -32,11 +32,11 @@ fs.readFile(filePath, 'utf8', (err, data) => { const updatedData = JSON.stringify(packageJson, null, 2); // Write the updated content back to the file - fs.writeFile(filePath, updatedData, 'utf8', (err) => { + fs.writeFile(filePath, updatedData, 'utf8', err => { if (err) { console.error('Error writing the file:', err); return; } console.log(`Updated 'type' to 'commonjs' in ${filePath}`); }); -}); \ No newline at end of file +}); diff --git a/docs/configuration.md b/docs/configuration.md index c3d2407c..7a6ddbfd 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -140,7 +140,6 @@ Use `/` separator to create a nested rungroup: TESTOMATIO={API_KEY} TESTOMATIO_RUNGROUP_TITLE="Builds/${BUILD_ID}" ``` - #### `TESTOMATIO_SHARED_RUN` Report parallel execution to the same run matching it by title. **If the run was created more than 20 minutes ago, a new run will be created instead.** To change the timeout use `TESTOMATIO_SHARED_RUN_TIMEOUT` variable. @@ -232,4 +231,4 @@ dotenv.config({ path: '.env' }); // or any other path It is recommended to read `.env` file as early as possible in your application, preferably on test runner initialization. E.g. in CodeceptJS you can do it in `codecept.conf.js` file. In Playwright: `playwright.config.js`. Jest: `jest.config.js`. Cypress: `cypress.config.js`. And so on. -It is recommended to add `.env` file to `.gitignore` to avoid committing sensitive data to the repository. \ No newline at end of file +It is recommended to add `.env` file to `.gitignore` to avoid committing sensitive data to the repository. diff --git a/docs/functions.md b/docs/functions.md index 0cb6ff87..e29b0e5d 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -102,7 +102,7 @@ test('my test', () => { browser: 'chrome', server: 'staging', }); -}) +}); ``` Or in CommonJS style: @@ -129,4 +129,4 @@ Supported frameworks: - 🟢 Jest - 🟢 Mocha - 🔴 Playwright (use native functionality instead) -- 🟢 WDIO (everything, except artifacts) \ No newline at end of file +- 🟢 WDIO (everything, except artifacts) diff --git a/lib/adapter/cypress-plugin/index.js b/lib/adapter/cypress-plugin/index.js index d679dd58..00d770e4 100644 --- a/lib/adapter/cypress-plugin/index.js +++ b/lib/adapter/cypress-plugin/index.js @@ -45,15 +45,17 @@ const testomatioReporter = on => { return this.message; }; } - const formattedError = error ? { - message: error.message, - name: error.name, - inspect: error.inspect || - // eslint-disable-next-line - function () { - return this.message; - }, - } : undefined; + const formattedError = error + ? { + message: error.message, + name: error.name, + inspect: error.inspect || + // eslint-disable-next-line + function () { + return this.message; + }, + } + : undefined; const screenshots = Array.isArray(results.screenshots) ? results.screenshots .filter(screenshot => screenshot?.path && screenshot?.path.includes(title) && screenshot?.takenAt) diff --git a/lib/adapter/playwright.js b/lib/adapter/playwright.js index e99b5ab9..c5c3b48f 100644 --- a/lib/adapter/playwright.js +++ b/lib/adapter/playwright.js @@ -57,13 +57,13 @@ class PlaywrightReporter { const rid = test.id || test.testId || (0, uuid_1.v4)(); /** * @type {{ - * browser?: string, - * dependencies: string[], - * isMobile?: boolean - * metadata: Record, - * name: string, - * }} - */ + * browser?: string, + * dependencies: string[], + * isMobile?: boolean + * metadata: Record, + * name: string, + * }} + */ const project = { browser: test.parent.project().use.defaultBrowserType, dependencies: test.parent.project().dependencies, @@ -71,7 +71,17 @@ class PlaywrightReporter { metadata: test.parent.project().metadata, name: test.parent.project().name, }; - const reportTestPromise = this.client.addTestRun(checkStatus(result.status), { + let status = result.status; + // process test.fail() annotation + if (test.expectedStatus === 'failed') { + // actual status = expected + if (result.status === 'failed') + status = 'passed'; + // actual status != expected + if (result.status === 'passed') + status = 'failed'; + } + const reportTestPromise = this.client.addTestRun(checkStatus(status), { rid: `${rid}-${project.name}`, error, test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${test.tags?.join(' ')}`), diff --git a/lib/adapter/webdriver.js b/lib/adapter/webdriver.js index 758b1b70..d18ca704 100644 --- a/lib/adapter/webdriver.js +++ b/lib/adapter/webdriver.js @@ -59,7 +59,7 @@ class WebdriverReporter extends reporter_1.default { } onRunnerStart() { // clear dir with artifacts/logs - // + // utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR); } onTestStart(test) { diff --git a/lib/client.js b/lib/client.js index 1add9a65..130e620f 100644 --- a/lib/client.js +++ b/lib/client.js @@ -44,7 +44,7 @@ const filesize_1 = require("filesize"); const debug = (0, debug_1.default)('@testomatio/reporter:client'); // removed __dirname usage, because: // 1. replaced with ESM syntax (import.meta.url), but it throws an error on tsc compilation; -// 2. got error "__dirname already defined" in compiles js code (cjs dir) +// 2. got error "__dirname already defined" in compiles js code (cjs dir) let listOfTestFilesToExcludeFromReport = null; /** * @typedef {import('../types/types.js').TestData} TestData @@ -55,7 +55,7 @@ class Client { * Create a Testomat client instance * @returns */ - // eslint-disable-next-line + // eslint-disable-next-line constructor(params = {}) { this.paramsForPipesFactory = params; this.pipeStore = {}; diff --git a/lib/pipe/debug.d.ts b/lib/pipe/debug.d.ts index df00b2e0..cddc7474 100644 --- a/lib/pipe/debug.d.ts +++ b/lib/pipe/debug.d.ts @@ -1,5 +1,7 @@ export class DebugPipe { constructor(params: any, store: any); + params: any; + store: any; isEnabled: boolean; batch: { isEnabled: any; @@ -9,7 +11,6 @@ export class DebugPipe { batchIndex: number; }; logFilePath: string; - store: any; testomatioEnvVars: {}; batchUpload(): Promise; /** diff --git a/lib/pipe/debug.js b/lib/pipe/debug.js index eb3a5ef6..f3ab0ae6 100644 --- a/lib/pipe/debug.js +++ b/lib/pipe/debug.js @@ -13,17 +13,18 @@ const pretty_ms_1 = __importDefault(require("pretty-ms")); const debug = (0, debug_1.default)('@testomatio/reporter:pipe:debug'); class DebugPipe { constructor(params, store) { + this.params = params || {}; + this.store = store || {}; this.isEnabled = !!process.env.TESTOMATIO_DEBUG || !!process.env.DEBUG; if (this.isEnabled) { this.batch = { - isEnabled: params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true, + isEnabled: this.params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true, intervalFunction: null, intervalTime: 5000, tests: [], batchIndex: 0, }; this.logFilePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.debug.${Date.now()}.json`); - this.store = store || {}; debug('Creating debug file:', this.logFilePath); fs_1.default.writeFileSync(this.logFilePath, ''); console.log(constants_js_1.APP_PREFIX, '🪲. Debug created:'); diff --git a/lib/pipe/index.js b/lib/pipe/index.js index a91e77b2..f9e1a0b5 100644 --- a/lib/pipe/index.js +++ b/lib/pipe/index.js @@ -77,9 +77,7 @@ async function pipesFactory(params, opts) { ...extraPipes, ]; const pipesEnabled = pipes.filter(p => p.isEnabled); - console.log(constants_js_1.APP_PREFIX, picocolors_1.default.cyan('Pipes:'), picocolors_1.default.cyan(pipesEnabled - .map(p => p.toString()) - .join(', ') || 'No pipes enabled')); + console.log(constants_js_1.APP_PREFIX, picocolors_1.default.cyan('Pipes:'), picocolors_1.default.cyan(pipesEnabled.map(p => p.toString()).join(', ') || 'No pipes enabled')); if (!pipesEnabled.length) { console.log(constants_js_1.APP_PREFIX, picocolors_1.default.dim('If you want to use Testomatio reporter, pass your token as TESTOMATIO env variable')); } diff --git a/lib/pipe/testomatio.js b/lib/pipe/testomatio.js index 7fce4c8b..1ff1a096 100644 --- a/lib/pipe/testomatio.js +++ b/lib/pipe/testomatio.js @@ -59,11 +59,13 @@ class TestomatioPipe { this.axios = axios_1.default.create({ baseURL: `${this.url.trim()}`, timeout: constants_js_1.AXIOS_TIMEOUT, - proxy: proxy ? { - host: proxy.hostname, - port: parseInt(proxy.port, 10), - protocol: proxy.protocol, - } : false, + proxy: proxy + ? { + host: proxy.hostname, + port: parseInt(proxy.port, 10), + protocol: proxy.protocol, + } + : false, }); // Pass the axios instance to the retry function (0, axios_retry_1.default)(this.axios, { @@ -224,7 +226,8 @@ class TestomatioPipe { const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10); if (cancelReporting) { this.reportingCanceledDueToReqFailures = true; - const errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES} requests were failed, reporting to Testomat aborted.`; + let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`; + errorMessage += ' requests were failed, reporting to Testomat aborted.'; console.warn(`${constants_js_1.APP_PREFIX} ${picocolors_1.default.yellow(errorMessage)}`); } return cancelReporting; @@ -243,9 +246,7 @@ class TestomatioPipe { } const json = json_cycle_1.default.stringify(data); debug('Adding test', json); - return this.axios - .post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig) - .catch(err => { + return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig).catch(err => { this.requestFailures++; this.notReportedTestsCount++; if (err.response) { diff --git a/lib/template/testomatio.hbs b/lib/template/testomatio.hbs index 4c1c1392..d71ba15e 100644 --- a/lib/template/testomatio.hbs +++ b/lib/template/testomatio.hbs @@ -1,15 +1,14 @@ - - + - - - + + + Report Testomat.io {{/if}} - + - +
-
- -
-
-
-
-

- automated job -

-
-
- {{#if runId}} -
-

Run

- #{{runId}} -
- {{/if}} -
-
- {{#if runUrl}} - - Full Report - - {{else}} - - {{/if}} -
-
-
+
+ +
+
+
+
+

+ automated job +

+
+
+ {{#if runId}} +
+

Run

+ #{{runId}} +
+ {{/if}} +
+
+ {{#if runUrl}} + + Full Report + + {{else}} + + {{/if}} +
- +
+
+ -
-
-
-

Testomatio Run Information

-
-
+
+
+
+

Testomatio Run Information

+
+
- -
-
-
-
-
+ +
+
+
+
+
+
+
+
+
+ +
+
+

Status

+
+
+
+

{{status}}

+
-
-
-
- -
-
-

Status

-
-
-
-

{{status}}

-
-
- - -
-
-

Execution Duration

-
- {{executionTime}} -
- - -
-
-

Tests

-
- {{tests.length}} -
- - -
-
-

Start Execution Date

-
- {{executionDate}} -
- + + +
+
+

Execution Duration

+
+ {{executionTime}} +
+ + +
+
+

Tests

+
+ {{tests.length}}
+ + +
+
+

Start Execution Date

+
+ {{executionDate}}
+ +
+
+
+ +
+
+
+
+ + + +
+
- -
-
-
-
- - - -
- -
-
+
+
+ +
+
+ +
+
-
-
-
+
- - + - + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9ce905e0..dd0e40cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "upload-artifacts": "lib/bin/uploadArtifacts.js" }, "devDependencies": { - "@playwright/test": "^1.46.1", + "@playwright/test": "^1.49.1", "@redocly/cli": "^1.0.0-beta.125", "@types/cross-spawn": "^6.0.6", "@types/cucumber": "^7.0.0", @@ -6501,13 +6501,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.48.2", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.2.tgz", - "integrity": "sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==", + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz", + "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.48.2" + "playwright": "1.49.1" }, "bin": { "playwright": "cli.js" @@ -25789,13 +25789,13 @@ } }, "node_modules/playwright": { - "version": "1.48.2", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.2.tgz", - "integrity": "sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==", + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz", + "integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.48.2" + "playwright-core": "1.49.1" }, "bin": { "playwright": "cli.js" @@ -25808,9 +25808,9 @@ } }, "node_modules/playwright-core": { - "version": "1.48.2", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.2.tgz", - "integrity": "sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==", + "version": "1.49.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz", + "integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 995183ba..6b6b07c1 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "build": "rm -rf ./cjs && tsc --module commonjs && npx tsx build/scripts/edit-js-files.js && npx tsx build/scripts/edit-package-json.js && chmod +x ./build/scripts/copy-tesmplate.sh && ./build/scripts/copy-tesmplate.sh" }, "devDependencies": { - "@playwright/test": "^1.46.1", + "@playwright/test": "^1.49.1", "@redocly/cli": "^1.0.0-beta.125", "@types/cross-spawn": "^6.0.6", "@types/cucumber": "^7.0.0", diff --git a/packages/newman-reporter-testomatio/src/index.ts b/packages/newman-reporter-testomatio/src/index.ts index 9ee8badc..39ec32af 100644 --- a/packages/newman-reporter-testomatio/src/index.ts +++ b/packages/newman-reporter-testomatio/src/index.ts @@ -294,11 +294,14 @@ function TestomatioNewmanReporter( debug('Run status update failed'); debug(err); }); - console.log(APP_PREFIX, + console.log( + APP_PREFIX, 'Collection run completed', status === 'passed' ? 'without failures' : `with ${summary.run.failures.length} failures`, ); - console.log(`${APP_PREFIX} Total requests sent: ${requestsCount}, failed requests: ${failedRequestsCount}, total tests: ${testsCount}`); + console.log( + `${APP_PREFIX} Total requests sent: ${requestsCount}, failed requests: ${failedRequestsCount}, total tests: ${testsCount}`, + ); }); } diff --git a/src/adapter/codecept.js b/src/adapter/codecept.js index ba83169d..9066bf38 100644 --- a/src/adapter/codecept.js +++ b/src/adapter/codecept.js @@ -321,7 +321,7 @@ async function uploadAttachments(client, attachments, messagePrefix, attachmentT // we are storing file if upload is disabled if (!client.uploader.isEnabled) return client.uploader.storeUploadedFile(path, client.runId, rid, false); - + return client.addTestRun(undefined, { ...stripExampleFromTitle(title), rid, diff --git a/src/adapter/cypress-plugin/index.js b/src/adapter/cypress-plugin/index.js index af62aa49..fa397617 100644 --- a/src/adapter/cypress-plugin/index.js +++ b/src/adapter/cypress-plugin/index.js @@ -1,7 +1,7 @@ import { STATUS } from '../../constants.js'; import { getTestomatIdFromTestTitle, parseSuite } from '../../utils/utils.js'; import TestomatClient from '../../client.js'; -import {config} from '../../config.js'; +import { config } from '../../config.js'; const testomatioReporter = on => { if (!config.TESTOMATIO) { @@ -50,7 +50,8 @@ const testomatioReporter = on => { }; } - const formattedError = error ? { + const formattedError = error + ? { message: error.message, name: error.name, inspect: @@ -59,7 +60,8 @@ const testomatioReporter = on => { function () { return this.message; }, - } : undefined; + } + : undefined; const screenshots = Array.isArray(results.screenshots) ? results.screenshots diff --git a/src/adapter/mocha.cjs b/src/adapter/mocha.cjs index 7a7b9ed8..45047c7d 100644 --- a/src/adapter/mocha.cjs +++ b/src/adapter/mocha.cjs @@ -1,2 +1,2 @@ -const MochaReporter = require('../../../lib/adapter/mocha/mocha.js'); +const MochaReporter = require('../../../lib/adapter/mocha.js'); module.exports = MochaReporter; diff --git a/src/adapter/playwright.js b/src/adapter/playwright.js index 45c90b83..c7717806 100644 --- a/src/adapter/playwright.js +++ b/src/adapter/playwright.js @@ -61,22 +61,31 @@ class PlaywrightReporter { /** * @type {{ - * browser?: string, - * dependencies: string[], - * isMobile?: boolean - * metadata: Record, - * name: string, - * }} - */ - const project = { - browser: test.parent.project().use.defaultBrowserType, - dependencies: test.parent.project().dependencies, - isMobile: test.parent.project().use.isMobile, - metadata: test.parent.project().metadata, - name: test.parent.project().name, - }; - - const reportTestPromise = this.client.addTestRun(checkStatus(result.status), { + * browser?: string, + * dependencies: string[], + * isMobile?: boolean + * metadata: Record, + * name: string, + * }} + */ + const project = { + browser: test.parent.project().use.defaultBrowserType, + dependencies: test.parent.project().dependencies, + isMobile: test.parent.project().use.isMobile, + metadata: test.parent.project().metadata, + name: test.parent.project().name, + }; + + let status = result.status; + // process test.fail() annotation + if (test.expectedStatus === 'failed') { + // actual status = expected + if (result.status === 'failed') status = 'passed'; + // actual status != expected + if (result.status === 'passed') status = 'failed'; + } + + const reportTestPromise = this.client.addTestRun(checkStatus(status), { rid: `${rid}-${project.name}`, error, test_id: getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`), diff --git a/src/adapter/webdriver.js b/src/adapter/webdriver.js index 211fe455..e736bc94 100644 --- a/src/adapter/webdriver.js +++ b/src/adapter/webdriver.js @@ -41,7 +41,7 @@ class WebdriverReporter extends WDIOReporter { onRunnerStart() { // clear dir with artifacts/logs - // + // fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR); } diff --git a/src/bin/cli.js b/src/bin/cli.js index 0ddde313..ad5c199c 100644 --- a/src/bin/cli.js +++ b/src/bin/cli.js @@ -8,7 +8,7 @@ import TestomatClient from '../client.js'; import XmlReader from '../xmlReader.js'; import { APP_PREFIX, STATUS } from '../constants.js'; import { version } from '../../package.json'; -import {config} from '../config.js'; +import { config } from '../config.js'; import { readLatestRunId } from '../utils/utils.js'; import pc from 'picocolors'; import { filesize as prettyBytes } from 'filesize'; @@ -245,7 +245,7 @@ program ); }); } - + const filesizeStrMaxLength = 7; if (client.uploader.failedUploads.length) { diff --git a/src/bin/reportXml.js b/src/bin/reportXml.js index a2bbf99b..e88dd84e 100755 --- a/src/bin/reportXml.js +++ b/src/bin/reportXml.js @@ -28,9 +28,9 @@ program console.log(APP_PREFIX, 'Loading env file:', opts.envFile); debug('Loading env file: %s', opts.envFile); dotenv.config({ path: opts.envFile }); - } + } lang = lang?.toLowerCase(); - if (javaTests === true || (lang === 'java' && !javaTests)) javaTests = 'src/test/java'; + if (javaTests === true || (lang === 'java' && !javaTests)) javaTests = 'src/test/java'; const runReader = new XmlReader({ javaTests, lang }); const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() }); if (!files.length) { @@ -46,7 +46,8 @@ program let timeoutTimer; if (opts.timelimit) { - timeoutTimer = setTimeout(() => { + timeoutTimer = setTimeout( + () => { console.log( `⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`, ); diff --git a/src/bin/uploadArtifacts.js b/src/bin/uploadArtifacts.js index 08724619..fba1c9b8 100644 --- a/src/bin/uploadArtifacts.js +++ b/src/bin/uploadArtifacts.js @@ -6,7 +6,7 @@ import createDebugMessages from 'debug'; import TestomatClient from '../client.js'; import { APP_PREFIX } from '../constants.js'; import { version } from '../../package.json'; -import {config} from '../config.js'; +import { config } from '../config.js'; import { readLatestRunId } from '../utils/utils.js'; import dotenv from 'dotenv'; diff --git a/src/client.js b/src/client.js index 50d2130a..43e9280f 100644 --- a/src/client.js +++ b/src/client.js @@ -7,7 +7,7 @@ import { randomUUID } from 'crypto'; import { APP_PREFIX, STATUS } from './constants.js'; import { pipesFactory } from './pipe/index.js'; import { glob } from 'glob'; -import path, { sep} from 'path'; +import path, { sep } from 'path'; import { fileURLToPath } from 'node:url'; import { S3Uploader } from './uploader.js'; import { formatStep, storeRunId } from './utils/utils.js'; @@ -17,7 +17,7 @@ const debug = createDebugMessages('@testomatio/reporter:client'); // removed __dirname usage, because: // 1. replaced with ESM syntax (import.meta.url), but it throws an error on tsc compilation; -// 2. got error "__dirname already defined" in compiles js code (cjs dir) +// 2. got error "__dirname already defined" in compiles js code (cjs dir) let listOfTestFilesToExcludeFromReport = null; @@ -31,7 +31,7 @@ class Client { * Create a Testomat client instance * @returns */ - // eslint-disable-next-line + // eslint-disable-next-line constructor(params = {}) { this.paramsForPipesFactory = params; this.pipeStore = {}; @@ -352,9 +352,7 @@ class Client { console.log( '\n', APP_PREFIX, - `🗄️ ${pc.bold(this.uploader.skippedUploads.length)} artifacts uploading 🟡${pc.bold( - 'skipped', - )}`, + `🗄️ ${pc.bold(this.uploader.skippedUploads.length)} artifacts uploading 🟡${pc.bold('skipped')}`, ); const skippedUploads = this.uploader.skippedUploads.map(file => ({ relativePath: file.path.replace(process.cwd(), ''), diff --git a/src/constants.js b/src/constants.js index 637e08ed..c05b96f7 100644 --- a/src/constants.js +++ b/src/constants.js @@ -5,7 +5,7 @@ import path from 'path'; const APP_PREFIX = pc.gray('[TESTOMATIO]'); const TESTOMATIO_REQUEST_TIMEOUT = parseInt(process.env.TESTOMATIO_REQUEST_TIMEOUT, 10); if (TESTOMATIO_REQUEST_TIMEOUT) { - console.log(`${APP_PREFIX} Request timeout is set to ${TESTOMATIO_REQUEST_TIMEOUT/1000}s`); + console.log(`${APP_PREFIX} Request timeout is set to ${TESTOMATIO_REQUEST_TIMEOUT / 1000}s`); } const AXIOS_TIMEOUT = TESTOMATIO_REQUEST_TIMEOUT || 20 * 1000; diff --git a/src/pipe/csv.js b/src/pipe/csv.js index e1ff8019..e7ffde82 100644 --- a/src/pipe/csv.js +++ b/src/pipe/csv.js @@ -1,7 +1,7 @@ import createDebugMessages from 'debug'; import path from 'path'; import fs from 'fs'; -import {createObjectCsvWriter} from 'csv-writer'; +import { createObjectCsvWriter } from 'csv-writer'; import pc from 'picocolors'; import merge from 'lodash.merge'; import { isSameTest, getCurrentDateTime, ansiRegExp } from '../utils/utils.js'; diff --git a/src/pipe/debug.js b/src/pipe/debug.js index f41301ab..d133e00c 100644 --- a/src/pipe/debug.js +++ b/src/pipe/debug.js @@ -9,17 +9,19 @@ const debug = createDebugMessages('@testomatio/reporter:pipe:debug'); export class DebugPipe { constructor(params, store) { + this.params = params || {}; + this.store = store || {}; + this.isEnabled = !!process.env.TESTOMATIO_DEBUG || !!process.env.DEBUG; if (this.isEnabled) { this.batch = { - isEnabled: params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true, + isEnabled: this.params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true, intervalFunction: null, intervalTime: 5000, tests: [], batchIndex: 0, }; this.logFilePath = path.join(os.tmpdir(), `testomatio.debug.${Date.now()}.json`); - this.store = store || {}; debug('Creating debug file:', this.logFilePath); fs.writeFileSync(this.logFilePath, ''); diff --git a/src/pipe/gitlab.js b/src/pipe/gitlab.js index 3d4e7671..c9a9c950 100644 --- a/src/pipe/gitlab.js +++ b/src/pipe/gitlab.js @@ -81,13 +81,13 @@ class GitLabPipe { let summary = `${this.hiddenCommentData} | [![Testomat.io Report](${testomatLogoURL})](https://testomat.io) | ${statusEmoji( - runParams.status, - )} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} | + runParams.status, + )} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} | | --- | --- | | Tests | ✔️ **${this.tests.length}** tests run | | Summary | ${statusEmoji('failed')} **${failedCount}** failed; ${statusEmoji( - 'passed', - )} **${passedCount}** passed; **${statusEmoji('skipped')}** ${skippedCount} skipped | + 'passed', + )} **${passedCount}** passed; **${statusEmoji('skipped')}** ${skippedCount} skipped | | Duration | 🕐 **${humanizeDuration( parseInt( this.tests.reduce((a, t) => a + (t.run_time || 0), 0), diff --git a/src/pipe/html.js b/src/pipe/html.js index d566215d..513baf22 100644 --- a/src/pipe/html.js +++ b/src/pipe/html.js @@ -7,7 +7,7 @@ import handlebars from 'handlebars'; import fileUrl from 'file-url'; import { fileSystem, isSameTest, ansiRegExp, formatStep } from '../utils/utils.js'; import { HTML_REPORT } from '../constants.js'; -import { fileURLToPath } from "node:url"; +import { fileURLToPath } from 'node:url'; const debug = createDebugMessages('@testomatio/reporter:pipe:html'); @@ -130,12 +130,11 @@ class HtmlPipe { tests.forEach(test => { // steps could be an array or a string test.steps = Array.isArray(test.steps) - ? (test.steps = test.steps - .map(step => formatStep(step)) - .flat() - .join('\n')) - : test.steps; - + ? (test.steps = test.steps + .map(step => formatStep(step)) + .flat() + .join('\n')) + : test.steps; if (!test.message?.trim()) { test.message = "This test has no 'message' code"; diff --git a/src/pipe/index.js b/src/pipe/index.js index 61b53a38..7fd49124 100644 --- a/src/pipe/index.js +++ b/src/pipe/index.js @@ -57,13 +57,9 @@ export async function pipesFactory(params, opts) { console.log( APP_PREFIX, pc.cyan('Pipes:'), - pc.cyan( - pipesEnabled - .map(p => p.toString()) - .join(', ') || 'No pipes enabled', - ), + pc.cyan(pipesEnabled.map(p => p.toString()).join(', ') || 'No pipes enabled'), ); - + if (!pipesEnabled.length) { console.log( APP_PREFIX, diff --git a/src/pipe/testomatio.js b/src/pipe/testomatio.js index 62f88391..356a5156 100644 --- a/src/pipe/testomatio.js +++ b/src/pipe/testomatio.js @@ -11,11 +11,10 @@ import JsonCycle from 'json-cycle'; import { APP_PREFIX, STATUS, AXIOS_TIMEOUT, REPORTER_REQUEST_RETRIES } from '../constants.js'; import { isValidUrl, foundedTestLog } from '../utils/utils.js'; import { parseFilterParams, generateFilterRequestParams, setS3Credentials } from '../utils/pipe_utils.js'; -import {config} from '../config.js'; +import { config } from '../config.js'; const debug = createDebugMessages('@testomatio/reporter:pipe:testomatio'); - if (process.env.TESTOMATIO_RUN) { // process.env.runId = process.env.TESTOMATIO_RUN; } @@ -64,11 +63,13 @@ class TestomatioPipe { this.axios = axios.create({ baseURL: `${this.url.trim()}`, timeout: AXIOS_TIMEOUT, - proxy: proxy ? { - host: proxy.hostname, - port: parseInt(proxy.port, 10), - protocol: proxy.protocol, - } : false, + proxy: proxy + ? { + host: proxy.hostname, + port: parseInt(proxy.port, 10), + protocol: proxy.protocol, + } + : false, }); // Pass the axios instance to the retry function @@ -232,7 +233,7 @@ class TestomatioPipe { console.error( APP_PREFIX, - 'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report' + 'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report', ); printCreateIssue(err); } @@ -249,8 +250,8 @@ class TestomatioPipe { const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10); if (cancelReporting) { this.reportingCanceledDueToReqFailures = true; - const errorMessage = - `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES} requests were failed, reporting to Testomat aborted.`; + let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`; + errorMessage += ' requests were failed, reporting to Testomat aborted.'; console.warn(`${APP_PREFIX} ${pc.yellow(errorMessage)}`); } return cancelReporting; @@ -272,36 +273,33 @@ class TestomatioPipe { debug('Adding test', json); - return this.axios - .post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig) - .catch(err => { - this.requestFailures++; - this.notReportedTestsCount++; - if (err.response) { - if (err.response.status >= 400) { - const responseData = err.response.data || { message: '' }; - console.log( - APP_PREFIX, - pc.yellow(`Warning: ${responseData.message} (${err.response.status})`), - pc.gray(data?.title || ''), - ); - if (err.response?.data?.message?.includes('could not be matched')) { - this.hasUnmatchedTests = true; - } - return; - } + return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig).catch(err => { + this.requestFailures++; + this.notReportedTestsCount++; + if (err.response) { + if (err.response.status >= 400) { + const responseData = err.response.data || { message: '' }; console.log( APP_PREFIX, - pc.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`), - `Report couldn't be processed: ${err?.response?.data?.message}`, + pc.yellow(`Warning: ${responseData.message} (${err.response.status})`), + pc.gray(data?.title || ''), ); - printCreateIssue(err); - } else { - console.log(APP_PREFIX, pc.blue(data?.title || ''), "Report couldn't be processed", err); + if (err.response?.data?.message?.includes('could not be matched')) { + this.hasUnmatchedTests = true; + } + return; } - }); - }; - + console.log( + APP_PREFIX, + pc.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`), + `Report couldn't be processed: ${err?.response?.data?.message}`, + ); + printCreateIssue(err); + } else { + console.log(APP_PREFIX, pc.blue(data?.title || ''), "Report couldn't be processed", err); + } + }); + }; /** * Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval @@ -321,7 +319,7 @@ class TestomatioPipe { this.batch.numberOfTimesCalledWithoutTests++; return; } - + this.batch.batchIndex++; // get tests from batch and clear batch const testsToSend = this.batch.tests.splice(0); @@ -386,7 +384,7 @@ class TestomatioPipe { */ async finishRun(params) { if (!this.isEnabled) return; - + await this.#batchUpload(); if (this.batch.intervalFunction) { clearInterval(this.batch.intervalFunction); @@ -456,11 +454,7 @@ class TestomatioPipe { console.log(APP_PREFIX, pc.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids'); console.log(APP_PREFIX, 'or for Cucumber:'); // eslint-disable-next-line max-len - console.log( - APP_PREFIX, - pc.bold('npx check-cucumber ... --update-ids'), - 'See: https://bit.ly/bdd-update-ids', - ); + console.log(APP_PREFIX, pc.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids'); } } catch (err) { console.log(APP_PREFIX, 'Error updating status, skipping...', err); diff --git a/src/reporter-functions.js b/src/reporter-functions.js index 442e2c85..eee4d2a7 100644 --- a/src/reporter-functions.js +++ b/src/reporter-functions.js @@ -5,7 +5,8 @@ import { services } from './services/index.js'; * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name */ function saveArtifact(data, context = null) { - if (process.env.IS_PLAYWRIGHT) throw new Error(`This function is not available in Playwright framework. + if (process.env.IS_PLAYWRIGHT) + throw new Error(`This function is not available in Playwright framework. /Playwright supports artifacts out of the box`); if (!data) return; services.artifacts.put(data, context); @@ -41,7 +42,7 @@ function setKeyValue(keyValue, value = null) { throw new Error('This function is not available in Playwright framework. Use test tag instead.'); if (typeof keyValue === 'string') { - keyValue = { [keyValue]: value } + keyValue = { [keyValue]: value }; } services.keyValues.put(keyValue); } diff --git a/src/reporter.js b/src/reporter.js index 87b9d429..4e4cc8be 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -3,7 +3,6 @@ import { services } from './services/index.js'; import reporterFunctions from './reporter-functions.js'; - export const artifact = reporterFunctions.artifact; export const log = reporterFunctions.log; export const logger = services.logger; diff --git a/src/services/logger.js b/src/services/logger.js index f2198690..068c661b 100644 --- a/src/services/logger.js +++ b/src/services/logger.js @@ -45,8 +45,10 @@ class Logger { logLevel = process?.env?.LOG_LEVEL?.toUpperCase() || 'ALL'; constructor() { - if (!dataStorage.isFileStorage || - (process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS&& process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS !== 'false')) + if ( + !dataStorage.isFileStorage || + (process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS && process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS !== 'false') + ) this.intercept(console); } diff --git a/src/template/testomatio.hbs b/src/template/testomatio.hbs index 4c1c1392..d71ba15e 100644 --- a/src/template/testomatio.hbs +++ b/src/template/testomatio.hbs @@ -1,15 +1,14 @@ - - + - - - + + + Report Testomat.io {{/if}} - + - +
-
- -
-
-
-
-

- automated job -

-
-
- {{#if runId}} -
-

Run

- #{{runId}} -
- {{/if}} -
-
- {{#if runUrl}} - - Full Report - - {{else}} - - {{/if}} -
-
-
+
+ +
+
+
+
+

+ automated job +

+
+
+ {{#if runId}} +
+

Run

+ #{{runId}} +
+ {{/if}} +
+
+ {{#if runUrl}} + + Full Report + + {{else}} + + {{/if}} +
- +
+
+ -
-
-
-

Testomatio Run Information

-
-
+
+
+
+

Testomatio Run Information

+
+
- -
-
-
-
-
+ +
+
+
+
+
+
+
+
+
+ +
+
+

Status

+
+
+
+

{{status}}

+
-
-
-
- -
-
-

Status

-
-
-
-

{{status}}

-
-
- - -
-
-

Execution Duration

-
- {{executionTime}} -
- - -
-
-

Tests

-
- {{tests.length}} -
- - -
-
-

Start Execution Date

-
- {{executionDate}} -
- + + +
+
+

Execution Duration

+
+ {{executionTime}} +
+ + +
+
+

Tests

+
+ {{tests.length}}
+ + +
+
+

Start Execution Date

+
+ {{executionDate}}
+ +
+
+
+ +
+
+
+
+ + + +
+
- -
-
-
-
- - - -
- -
-
+
+
+ +
+
+ +
+
-
-
-
+
- - + - + \ No newline at end of file diff --git a/src/uploader.js b/src/uploader.js index 0390062f..c17b1092 100644 --- a/src/uploader.js +++ b/src/uploader.js @@ -47,7 +47,7 @@ export class S3Uploader { } /** - * + * * @returns {Record} */ getConfig() { @@ -111,20 +111,20 @@ export class S3Uploader { debug('Uploading to S3:', Key); - const s3Config = this.#getS3Config() + const s3Config = this.#getS3Config(); const s3 = new S3(s3Config); const params = { Bucket: S3_BUCKET, Key, Body, - } + }; // disable ACL for I AM roles if (!s3Config.credentials.sessionToken) { params.ACL = ACL; } try { - const upload = new Upload({client: s3,params}); + const upload = new Upload({ client: s3, params }); const link = await this.getS3LocationLink(upload); this.successfulUploads.push({ path: file.path, size: file.size, link }); @@ -249,9 +249,7 @@ export class S3Uploader { const skippedArtifact = { path: filePath, size: fileSize }; this.storeUploadedFile(filePath, runId, rid, false); this.skippedUploads.push(skippedArtifact); - debug( - pc.yellow(`Artifacts file ${JSON.stringify(skippedArtifact)} exceeds the maximum allowed size. Skipping.`), - ); + debug(pc.yellow(`Artifacts file ${JSON.stringify(skippedArtifact)} exceeds the maximum allowed size. Skipping.`)); return; } debug('File:', filePath, 'exists, size:', prettyBytes(fileSize)); diff --git a/src/utils/pipe_utils.js b/src/utils/pipe_utils.js index fcf00a55..e0470043 100644 --- a/src/utils/pipe_utils.js +++ b/src/utils/pipe_utils.js @@ -15,8 +15,8 @@ function setS3Credentials(artifacts) { if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET; if (artifacts.SESSION_TOKEN) process.env.S3_SESSION_TOKEN = artifacts.SESSION_TOKEN; if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1'; - // endpoint is not received from the server; and shuld be empty if IAM used (credentails obtained from the testomat) - process.env.S3_ENDPOINT = artifacts.ENDPOINT || ''; + // endpoint is not received from the server; and shuld be empty if IAM used (credentails obtained from the testomat) + process.env.S3_ENDPOINT = artifacts.ENDPOINT || ''; } /** @@ -116,11 +116,4 @@ function fullName(t) { return line; } -export { - updateFilterType, - parseFilterParams, - generateFilterRequestParams, - setS3Credentials, - statusEmoji, - fullName, -}; +export { updateFilterType, parseFilterParams, generateFilterRequestParams, setS3Credentials, statusEmoji, fullName }; diff --git a/src/xmlReader.js b/src/xmlReader.js index 09343b7b..31748ec4 100644 --- a/src/xmlReader.js +++ b/src/xmlReader.js @@ -14,9 +14,9 @@ import { fetchIdFromCode, humanize, } from './utils/utils.js'; -import {pipesFactory} from './pipe/index.js'; +import { pipesFactory } from './pipe/index.js'; import adapterFactory from './junit-adapter/index.js'; -import {config} from './config.js'; +import { config } from './config.js'; import { S3Uploader } from './uploader.js'; // @ts-ignore this line will be removed in compiled code, because __dirname is defined in commonjs @@ -26,8 +26,8 @@ const debug = createDebugMessages('@testomatio/reporter:xml'); const ridRunId = randomUUID(); const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io'; -const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, - TESTOMATIO_MARK_DETACHED } = process.env; +const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } = + process.env; const options = { ignoreDeclaration: true, diff --git a/tests/adapter/config/index.js b/tests/adapter/config/index.js index 706587d2..48d22d43 100644 --- a/tests/adapter/config/index.js +++ b/tests/adapter/config/index.js @@ -1,7 +1,7 @@ const host = 'localhost'; const port = 19000; -export const config = { +export const config = { host, port, TESTOMATIO_URL: `http://${host}:${port}`, diff --git a/tests/adapter/examples/codecept/steps_file.js b/tests/adapter/examples/codecept/steps_file.js index 88264fb7..a62c583f 100644 --- a/tests/adapter/examples/codecept/steps_file.js +++ b/tests/adapter/examples/codecept/steps_file.js @@ -5,4 +5,4 @@ export default function () { // Define custom steps here, use 'this' to access default methods of I. // It is recommended to place a general 'login' function here. }); -}; +} diff --git a/tests/adapter/examples/cucumber/cucumber.js b/tests/adapter/examples/cucumber/cucumber.js index 6efa9d4c..aac66f21 100644 --- a/tests/adapter/examples/cucumber/cucumber.js +++ b/tests/adapter/examples/cucumber/cucumber.js @@ -1,7 +1,7 @@ export default { // default: `--publish-quiet -f ../../../../lib/adapter/cucumber.js`, // format: ['progress', 'node_modules/@testomatio/reporter/lib/adapter/cucumber.js'] - format: ['--publish-quiet', '../../../../lib/adapter/cucumber/current.js'] + format: ['--publish-quiet', '../../../../lib/adapter/cucumber/current.js'], // format: ['--publish-quiet', '../../../../lib/adapter/cucumber/current.js'] // format: ['summary'] }; diff --git a/tests/adapter/examples/jasmine/passReporterOpts.js b/tests/adapter/examples/jasmine/passReporterOpts.js index 418f8c1f..6aa6938e 100644 --- a/tests/adapter/examples/jasmine/passReporterOpts.js +++ b/tests/adapter/examples/jasmine/passReporterOpts.js @@ -1,4 +1,3 @@ - // // file is updated (was: loadConfig.js) // const path = process.cwd() + '/node_modules/jasmine/lib/command.js'; // const apiKey = process.env.TESTOMATIO; @@ -24,4 +23,4 @@ // } // console.log('Replacement successful.'); // }); -// }); \ No newline at end of file +// }); diff --git a/tests/adapter/examples/mocha/mocha.config.cjs b/tests/adapter/examples/mocha/mocha.config.cjs index 8be1dfec..8dcff9bb 100644 --- a/tests/adapter/examples/mocha/mocha.config.cjs +++ b/tests/adapter/examples/mocha/mocha.config.cjs @@ -1,4 +1,4 @@ module.exports = { - reporter: './lib/adapter/mocha/mocha.js', - reporterOptions: process.env.TESTOMATIO ? `apiKey=${process.env.TESTOMATIO}` : '', + reporter: './lib/adapter/mocha.js', + reporterOptions: process.env.TESTOMATIO ? `apiKey=${process.env.TESTOMATIO}` : '', }; diff --git a/tests/adapter/examples/playwright/playwright.config.ts b/tests/adapter/examples/playwright/playwright.config.ts index ab640551..a2840c36 100644 --- a/tests/adapter/examples/playwright/playwright.config.ts +++ b/tests/adapter/examples/playwright/playwright.config.ts @@ -1,14 +1,19 @@ import { PlaywrightTestConfig } from '@playwright/test'; +// test fails on CI with this type if NODE=v23: +// SyntaxError: The requested module '@playwright/test' does not provide an export named 'PlaywrightTestConfig' // Reference: https://playwright.dev/docs/test-configuration const config: PlaywrightTestConfig = { testMatch: '/tests/*.spec.js', reporter: [ ['list'], // ['@testomatio/reporter/lib/adapter/playwright.js', { - ['../../../../lib/adapter/playwright.js', { - apiKey: process.env.TESTOMATIO, - }] - ] + [ + '../../../../lib/adapter/playwright.js', + { + apiKey: process.env.TESTOMATIO, + }, + ], + ], }; export default config; diff --git a/tests/adapter/examples/playwright/tests/smoke-test-1.spec.js b/tests/adapter/examples/playwright/tests/smoke-test-1.spec.js index 245cc200..87161e51 100644 --- a/tests/adapter/examples/playwright/tests/smoke-test-1.spec.js +++ b/tests/adapter/examples/playwright/tests/smoke-test-1.spec.js @@ -4,4 +4,4 @@ test.describe('Smoke case-1', () => { const title = 'Playwright'; expect(title).toEqual('Playwright'); }); -}); \ No newline at end of file +}); diff --git a/tests/adapter/examples/vitest/vite.config.ts b/tests/adapter/examples/vitest/vite.config.ts index 8bc6d4f1..368ea990 100644 --- a/tests/adapter/examples/vitest/vite.config.ts +++ b/tests/adapter/examples/vitest/vite.config.ts @@ -2,11 +2,11 @@ // Configure Vitest (https://vitest.dev/config/) -import { defineConfig } from 'vite' +import { defineConfig } from 'vite'; export default defineConfig({ test: { /* for example, use global to avoid globals imports (describe, test, expect): */ // globals: true, }, -}) +}); diff --git a/tests/adapter/index.test.js b/tests/adapter/index.test.js index c2c9175a..8cd8c073 100644 --- a/tests/adapter/index.test.js +++ b/tests/adapter/index.test.js @@ -2,7 +2,7 @@ import { assert, expect } from 'chai'; import { exec } from 'child_process'; import ServerMock from 'mock-http-server'; import JestReporter from '../../lib/adapter/jest.js'; -import { JasmineReporter } from '../../lib/adapter/jasmine/jasmine.js'; +import { JasmineReporter } from '../../lib/adapter/jasmine.js'; // import { CodeceptReporter } from '../../lib/adapter/codecept.js'; import CucumberReporter from '../../lib/adapter/cucumber/current.js'; import { registerHandlers } from './utils/index.js'; @@ -21,7 +21,7 @@ const params = [ positiveCmd: `TESTOMATIO_URL=${TESTOMATIO_URL} TESTOMATIO=${TESTOMATIO} npm run test:adapter:jest:example`, negativeCmd: `TESTOMATIO_URL=${TESTOMATIO_URL} npm run test:adapter:jest:example`, }, - + { adapterName: 'MochaReporter', positiveCmd: `TESTOMATIO_URL=${TESTOMATIO_URL} TESTOMATIO=${TESTOMATIO} npm run test:adapter:mocha:example`, @@ -52,7 +52,7 @@ const params = [ adapterName: 'Playwright', positiveCmd: `TESTOMATIO_URL=${TESTOMATIO_URL} TESTOMATIO=${TESTOMATIO} npm run test:adapter:playwright:example`, negativeCmd: `TESTOMATIO_URL=${TESTOMATIO_URL} npm run test:adapter:playwright:example`, - } + }, ]; describe('Adapters', () => { diff --git a/tests/data/src/error.js b/tests/data/src/error.js index 0f54accb..78c7bf98 100644 --- a/tests/data/src/error.js +++ b/tests/data/src/error.js @@ -1,3 +1,3 @@ export default function () { throw new Error('Test error'); -}; +} diff --git a/tests/pipes/debug_pipe_test.js b/tests/pipes/debug_pipe_test.js index e7b5ef63..f6259b98 100644 --- a/tests/pipes/debug_pipe_test.js +++ b/tests/pipes/debug_pipe_test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import fs from 'fs'; -import DebugPipe from '../../lib/pipe/debug.js'; +import {DebugPipe} from '../../lib/pipe/debug.js'; const LOG_DATA = { action: 'testAction', @@ -33,8 +33,8 @@ describe('DebugPipe logging tests', () => { data: 'variables', testomatioEnvVars: debugPipe.testomatioEnvVars, }) - // cut curly braces at start and end - .slice(1, -1), + // cut curly braces at start and end + .slice(1, -1), ); expect(savedData[2]).to.contain(JSON.stringify({ data: 'store', store: {} }).slice(1, -1)); expect(savedData[3]).to.contain(JSON.stringify(LOG_DATA).slice(1, -1)); diff --git a/tests/xmlReader_test.js b/tests/xmlReader_test.js index a06f9f96..199b788a 100644 --- a/tests/xmlReader_test.js +++ b/tests/xmlReader_test.js @@ -7,7 +7,7 @@ import XmlReader from '../lib/xmlReader.js'; import { fileURLToPath } from 'url'; const dirname = path.dirname(fileURLToPath(import.meta.url)); -const {host, port, TESTOMATIO_URL, TESTOMATIO, RUN_ID} = config; +const { host, port, TESTOMATIO_URL, TESTOMATIO, RUN_ID } = config; describe('XML Reader', () => { const server = new ServerMock({ host, port }); diff --git a/tsconfig.json b/tsconfig.json index 9cae066d..080141da 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,12 +16,10 @@ "typeRoots": ["./types", "./node_modules/@types"], "target": "ES2022", "rootDir": "./src", - "outDir": "./lib", // change for esm + "outDir": "./lib" // change for esm }, "compileOnSave": true, - "include": [ - "src/", - ], + "include": ["src/"], "exclude": [ "node_modules", "packages", @@ -29,6 +27,6 @@ "src/adapter/**/*.cjs", // "src/adapter/mocha.cjs", // "src/adapter/jasmine/jasmine.cjs", - "src/reporter.cjs_decprecated", - ], -} \ No newline at end of file + "src/reporter.cjs_decprecated" + ] +} diff --git a/types/types.d.ts b/types/types.d.ts index 415807b8..743dc837 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -13,7 +13,7 @@ declare module '@testomatio/reporter' { export const artifact: typeof reporterFunctions.artifact; export const log: typeof reporterFunctions.log; export const meta: typeof reporterFunctions.keyValue; -}; +} export interface FileType { path: string;