@alex_neo/playwright-azure-reporter 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ "node": true
6
+ },
7
+ extends: [
8
+ 'eslint:recommended'
9
+ ],
10
+ parser: '@typescript-eslint/parser',
11
+ parserOptions: {
12
+ ecmaVersion: 12,
13
+ sourceType: 'module'
14
+ },
15
+ plugins: [
16
+ '@typescript-eslint'
17
+ ],
18
+ rules: {
19
+ 'no-async-promise-executor': 0
20
+ }
21
+ }
@@ -0,0 +1,25 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ packages: write
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: '16.x'
18
+ registry-url: 'https://registry.npmjs.org'
19
+ # Defaults to the user or organization that owns the workflow file
20
+ scope: '@alex_neo'
21
+ - run: npm ci
22
+ - run: npm run build
23
+ - run: npm publish --access public
24
+ env:
25
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Playwright Azure Reporter
2
+
3
+ ## How to integrate
4
+
5
+ ```
6
+ npm install @alex-neo/playwright-azure-reporter
7
+ ```
8
+
9
+ ## Usage
10
+ You must register an ID already existing test cases from Azure DevOps before running tests.
11
+
12
+ **You need write testCaseId inside square brackets at the test name.**
13
+
14
+ For example:
15
+
16
+ ```typescript
17
+ describe('Test suite', () => {
18
+ test('[1] First Test', () => {
19
+ expect(true).toBe(true);
20
+ })
21
+
22
+ test('[3] Correct test', () => {
23
+ expect(true).toBe(true);
24
+ })
25
+
26
+ test.skip('[4] Skipped test', () => {
27
+ expect(true).toBe(true);
28
+ })
29
+
30
+ test('[6] Failed test', () => {
31
+ expect(true).toBe(false);
32
+ })
33
+ });
34
+
35
+ ```
36
+ You can use external file with Azure DevOps config values
37
+
38
+ ```azure.config.json```
39
+ ```json
40
+ {
41
+ "token": "AZURE-TOKEN",
42
+ "orgUrl": "https://dev.azure.com/alex-neo",
43
+ "projectName": "SampleProject",
44
+ "testPlanId": 4
45
+ }
46
+ ```
47
+
48
+ Configure Playwright Azure Reporter with `playwright-azure-reporter` package.
49
+
50
+ ```playwright.config.ts```
51
+ ```typescript
52
+ import { PlaywrightTestConfig } from '@playwright/test'
53
+ import azureConfig from './azure.config.json'
54
+
55
+ const config: PlaywrightTestConfig = {
56
+ testDir: './tests',
57
+ timeout: 30 * 1000,
58
+ reporter: [
59
+ ['list'],
60
+ [
61
+ '@alex-neo/playwright-azure-reporter',
62
+ {
63
+ token: azureConfig.token,
64
+ orgUrl: azureConfig.orgUrl,
65
+ projectName: azureConfig.projectName,
66
+ planId: azureConfig.testPlanId,
67
+ environment: 'QA',
68
+ testRunTitle: 'Playwright Test Run',
69
+ uploadAttachments: true
70
+ isDisabled: false,
71
+ }
72
+ ]
73
+ ],
74
+ use: {
75
+ screenshot: 'only-on-failure',
76
+ }
77
+
78
+ }
79
+
80
+ export default config
81
+
82
+ ```
83
+
84
+ ## Configuration
85
+
86
+ Reporter options (* - required):
87
+
88
+ - *`token` - Azure DevOps token, you can find more information [here](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows)
89
+ - *`orgUrl` - Full url for your organization space. Example: `https://dev.azure.com/alex-neo`
90
+ - *`projectName` - Name of your project (also can be got from run URL). Example: `https://dev.azure.com/alex-neo/SampleProject/` - __SampleProject__
91
+ - *`planId` - Id of test plan. You can find it in test plan URL. Example: `https://dev.azure.com/alex-neo/SampleProject/_testPlans/execute?planId=4&suiteId=6` - __planId=4__
92
+ - `environment` - Any string that will be used as environment name. Will be used as prefix for all test runs. Default: `undefined`. Example: `QA`
93
+ - `logging` [true/false] - Enabled debug logging from reporter or not. Default: `true`.
94
+ - `uploadAttachments` [true/false] - Uploading attachments (screenshot/video) after test ended. Default: `false`.
95
+ - `isDisabled` [true/false] - Disable reporter. Default: `false`.
96
+ - `testRunTitle` - Title of test run. Default: `Playwright Test Run`.
@@ -0,0 +1,6 @@
1
+ {
2
+ "token": "fbflfrmrw6ituk2ykeox5klqwoyzdtuvpyl4bee5fxak2ln3gqza",
3
+ "orgUrl": "https://dev.azure.com/alex-neo",
4
+ "projectName": "SampleProject",
5
+ "testPlanId": 4
6
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@alex_neo/playwright-azure-reporter",
3
+ "version": "1.0.1",
4
+ "description": "Playwright Azure Reporter",
5
+ "main": "./dist/playwright-azure-reporter.js",
6
+ "scripts": {
7
+ "test": "npx playwright test",
8
+ "lint": "eslint src/**",
9
+ "lint:fix": "eslint --fix src/**",
10
+ "build": "npm run clean && npm run dev",
11
+ "clean": "rm -rf dist || true",
12
+ "prepublishOnly": "npm run lint",
13
+ "dev": "npm run lint && tsc",
14
+ "dev:watch": "nodemon --watch src --exec \"npm run build\""
15
+ },
16
+ "keywords": [
17
+ "playwright",
18
+ "azure",
19
+ "reporter"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/alexneo2003/playwright-azure-reporter.git"
24
+ },
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "author": {
29
+ "name": "Oleksii Galagan",
30
+ "email": "alexneo2003@gmail.com",
31
+ "url": "https://github.com/alexneo2003/"
32
+ },
33
+ "license": "ISC",
34
+ "dependencies": {
35
+ "azure-devops-node-api": "^11.1.1",
36
+ "chalk": "4.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "@playwright/test": "^1.22.2",
40
+ "@typescript-eslint/eslint-plugin": "^5.27.1",
41
+ "@typescript-eslint/eslint-plugin-tslint": "^5.27.1",
42
+ "@typescript-eslint/parser": "^5.27.1",
43
+ "chalk": "^4.1.0",
44
+ "eslint": "^8.17.0",
45
+ "eslint-config-standard": "^17.0.0",
46
+ "eslint-plugin-import": "^2.26.0",
47
+ "eslint-plugin-jsdoc": "^39.3.2",
48
+ "eslint-plugin-n": "^15.2.2",
49
+ "eslint-plugin-prefer-arrow": "^1.2.2",
50
+ "eslint-plugin-promise": "^6.0.0"
51
+ }
52
+ }
@@ -0,0 +1,68 @@
1
+ import { PlaywrightTestConfig } from '@playwright/test'
2
+ import azureConfig from './azure.config.json'
3
+
4
+ /**
5
+ * Read environment variables from file.
6
+ * https://github.com/motdotla/dotenv
7
+ */
8
+ // require('dotenv').config();
9
+
10
+ /**
11
+ * See https://playwright.dev/docs/test-configuration.
12
+ */
13
+ const config: PlaywrightTestConfig = {
14
+ testDir: './tests',
15
+ /* Maximum time one test can run for. */
16
+ timeout: 30 * 1000,
17
+ expect: {
18
+ /**
19
+ * Maximum time expect() should wait for the condition to be met.
20
+ * For example in `await expect(locator).toHaveText();`
21
+ */
22
+ timeout: 5000
23
+ },
24
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
25
+ forbidOnly: !!process.env.CI,
26
+ /* Retry on CI only */
27
+ retries: process.env.CI ? 2 : 0,
28
+ /* Opt out of parallel tests on CI. */
29
+ workers: process.env.CI ? 1 : undefined,
30
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
31
+ reporter: [
32
+ ['list'],
33
+ [
34
+ './src/playwright-azure-reporter.ts',
35
+ {
36
+ orgUrl: azureConfig.orgUrl,
37
+ token: azureConfig.token,
38
+ planId: azureConfig.testPlanId,
39
+ projectName: azureConfig.projectName,
40
+ // environment: 'AQA',
41
+ testRunTitle: 'Playwright Test Run',
42
+ uploadAttachments: false
43
+ }
44
+ ]
45
+ ],
46
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
47
+ use: {
48
+ screenshot: 'only-on-failure',
49
+ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
50
+ actionTimeout: 0,
51
+ /* Base URL to use in actions like `await page.goto('/')`. */
52
+ // baseURL: 'http://localhost:3000',
53
+
54
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
55
+ trace: 'on-first-retry'
56
+ }
57
+
58
+ /* Folder for test artifacts such as screenshots, videos, traces, etc. */
59
+ // outputDir: 'test-results/',
60
+
61
+ /* Run your local dev server before starting the tests */
62
+ // webServer: {
63
+ // command: 'npm run start',
64
+ // port: 3000,
65
+ // },
66
+ }
67
+
68
+ export default config
@@ -0,0 +1,381 @@
1
+ /* eslint-disable no-control-regex */
2
+ import * as Test from 'azure-devops-node-api/TestApi'
3
+ import * as TestInterfaces from 'azure-devops-node-api/interfaces/TestInterfaces'
4
+ import * as azdev from 'azure-devops-node-api'
5
+
6
+ import { Reporter, TestCase, TestResult } from '@playwright/test/reporter'
7
+
8
+ import { TestPoint } from 'azure-devops-node-api/interfaces/TestInterfaces'
9
+ import { WebApi } from 'azure-devops-node-api'
10
+ import chalk from 'chalk'
11
+ import { readFileSync } from 'fs'
12
+
13
+ const Statuses = {
14
+ passed: 'Passed',
15
+ failed: 'Failed',
16
+ skipped: 'Paused',
17
+ timedOut: 'Failed'
18
+ }
19
+
20
+ interface AzureOptions {
21
+ token: string;
22
+ planId: number;
23
+ orgUrl: string;
24
+ connection: WebApi;
25
+ projectName: string;
26
+ runId?: string;
27
+ logging?: boolean;
28
+ isDisabled?: boolean;
29
+ environment?: string | undefined;
30
+ testRunTitle: string;
31
+ uploadAttachments?: boolean;
32
+ }
33
+
34
+ interface TestResultsToTestRun {
35
+ statusCode: number;
36
+ result: Result;
37
+ headers: Headers;
38
+ }
39
+ interface Result {
40
+ count: number;
41
+ value?: ValueEntity[] | null;
42
+ }
43
+ interface ValueEntity {
44
+ id: number;
45
+ project: Project;
46
+ outcome: string;
47
+ testRun: TestRun;
48
+ priority: number;
49
+ url: string;
50
+ lastUpdatedBy: LastUpdatedBy;
51
+ }
52
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
53
+ interface Project {
54
+ }
55
+ interface TestRun {
56
+ id: string;
57
+ }
58
+ interface LastUpdatedBy {
59
+ displayName?: null;
60
+ id?: null;
61
+ }
62
+ interface Headers {
63
+ 'cache-control': string;
64
+ 'pragma': string;
65
+ 'content-length': string;
66
+ 'content-type': string;
67
+ 'expires': string;
68
+ 'p3p': string;
69
+ 'x-tfs-processid': string;
70
+ 'strict-transport-security': string;
71
+ 'activityid': string;
72
+ 'x-tfs-session': string;
73
+ 'x-vss-e2eid': string;
74
+ 'x-vss-senderdeploymentid': string;
75
+ 'x-vss-userdata': string;
76
+ 'x-frame-options': string;
77
+ 'request-context': string;
78
+ 'access-control-expose-headers': string;
79
+ 'x-content-type-options': string;
80
+ 'x-cache': string;
81
+ 'x-msedge-ref': string;
82
+ 'date': string;
83
+ 'connection': string;
84
+ }
85
+
86
+ const alwaysUndefined = () => undefined
87
+
88
+ class PlaywrightReporter implements Reporter {
89
+ private testApi!: Test.ITestApi;
90
+ private options: AzureOptions;
91
+ private planId: number | string;
92
+ private runId?: number;
93
+ private isDisabled = false;
94
+ private publishedResultsCount = 0;
95
+ private resultsToBePublished: string[] = [];
96
+ private orgUrl: string;
97
+ private connection: WebApi;
98
+ private projectName: string;
99
+ private environment: string | undefined;
100
+ private logging = true;
101
+ private testRunTitle: string;
102
+
103
+ public constructor (_options: AzureOptions) {
104
+ this.options = _options
105
+ this.orgUrl = _options.orgUrl
106
+ this.projectName = _options.projectName
107
+ this.environment = _options.environment || undefined
108
+ this.planId = _options.planId
109
+ this.logging = _options.logging || true
110
+ this.isDisabled = _options.isDisabled || false
111
+ this.testRunTitle = `${this.environment ? `[${this.environment}]:` : ''} ${_options.testRunTitle || 'Playwright Test Run'}` ||
112
+ `${this.environment ? `[${this.environment}]:` : ''}Test plan ${this.planId}`
113
+ this.connection = new azdev.WebApi(this.orgUrl, azdev.getPersonalAccessTokenHandler(this.options.token))
114
+ this.options.uploadAttachments = _options.uploadAttachments || false
115
+
116
+ if (!this.orgUrl) {
117
+ this.log(chalk`{yellow 'orgUrl' is not set. Reporting is disabled.}`)
118
+ this.isDisabled = true
119
+ return
120
+ }
121
+ if (!this.projectName || !this.planId) {
122
+ this.log(chalk`{yellow 'projectName' is not set. Reporting is disabled.}`)
123
+ this.isDisabled = true
124
+ return
125
+ }
126
+ if (!this.planId) {
127
+ this.log(chalk`{yellow 'planId' is not set. Reporting is disabled.}`)
128
+ this.isDisabled = true
129
+ return
130
+ }
131
+ if (!this.options.token) {
132
+ this.log(chalk`{yellow 'token' is not set. Reporting is disabled.}`)
133
+ this.isDisabled = true
134
+ }
135
+ }
136
+
137
+ public async onBegin (): Promise<void> {
138
+ if (this.isDisabled) {
139
+ return
140
+ }
141
+ this.testApi = await this.connection.getTestApi()
142
+
143
+ return this.createRun(this.testRunTitle, (created) => {
144
+ if (created) {
145
+ this.runId = created.id
146
+ this.log(chalk`{green Using run ${this.runId} to publish test results}`)
147
+ } else {
148
+ this.log(chalk`{red Could not create run in project ${this.options.projectName}}`)
149
+ this.isDisabled = true
150
+ }
151
+ })
152
+ }
153
+
154
+ public async onTestEnd (test: TestCase, testResult: TestResult): Promise<void> {
155
+ if (this.isDisabled) {
156
+ return
157
+ }
158
+
159
+ return this.publishCaseResult(test, testResult).then(alwaysUndefined)
160
+ }
161
+
162
+ public async onEnd (): Promise<void> {
163
+ if (this.isDisabled) {
164
+ return
165
+ }
166
+
167
+ let prevCount = this.resultsToBePublished.length
168
+ while (this.resultsToBePublished.length > 0) {
169
+ // need wait all results to be published
170
+ if (prevCount > this.resultsToBePublished.length) {
171
+ this.log(
172
+ chalk`{gray Waiting for all results to be published. Remaining ${this.resultsToBePublished.length} results}`
173
+ )
174
+ prevCount--
175
+ }
176
+ await new Promise((resolve) => setTimeout(resolve, 250))
177
+ }
178
+
179
+ if (this.publishedResultsCount === 0 && !this.runId) {
180
+ this.log('No testcases were matched. Ensure that your tests are declared correctly.')
181
+ return
182
+ }
183
+
184
+ try {
185
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
186
+ const runUpdate: TestInterfaces.RunUpdateModel = {
187
+ state: 'Completed'
188
+ }
189
+ const runUpdated = await this.testApi.updateTestRun(runUpdate, this.projectName, this.runId as number)
190
+ this.log(chalk`{green Run ${this.runId} - ${runUpdated.state}}`)
191
+ } catch (err) {
192
+ this.log(`Error on completing run ${err as string}`)
193
+ }
194
+ }
195
+
196
+ private log (message?: any) {
197
+ if (this.logging) {
198
+ // eslint-disable-next-line no-console
199
+ console.log(chalk`{bold {magenta azure:} ${message}}`)
200
+ }
201
+ }
202
+
203
+ private getCaseIds (test: TestCase): string {
204
+ const regexp = /\[([\d,]+)\]/
205
+ const results = regexp.exec(test.title)
206
+ if (results && results.length === 2) {
207
+ return results[1]
208
+ }
209
+ return ''
210
+ }
211
+
212
+ private logTestItem (test: TestCase, testResult: TestResult) {
213
+ const map = {
214
+ failed: chalk`{red Test ${test.title} ${testResult.status}}`,
215
+ passed: chalk`{green Test ${test.title} ${testResult.status}}`,
216
+ skipped: chalk`{blueBright Test ${test.title} ${testResult.status}}`,
217
+ pending: chalk`{blueBright Test ${test.title} ${testResult.status}}`,
218
+ disabled: chalk`{gray Test ${test.title} ${testResult.status}}`,
219
+ timedOut: chalk`{gray Test ${test.title} ${testResult.status}}`
220
+ }
221
+ if (testResult.status) {
222
+ this.log(map[testResult.status])
223
+ }
224
+ }
225
+
226
+ // eslint-disable-next-line no-unused-vars
227
+ private async createRun (runName: string, cb: (adTestRun: TestInterfaces.TestRun | undefined) => void): Promise<void> {
228
+ try {
229
+ const runModel: TestInterfaces.RunCreateModel = {
230
+ name: runName,
231
+ automated: true,
232
+ configurationIds: [1],
233
+ plan: { id: `${this.planId}` }
234
+ }
235
+ const adTestRun = await this.testApi.createTestRun(runModel, this.projectName)
236
+ cb(adTestRun)
237
+ } catch (e) {
238
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
239
+ this.log(`While creating test points ids. Error: ${e}`)
240
+ this.isDisabled = true
241
+ }
242
+ }
243
+
244
+ private removePublished (testAlias: string): void {
245
+ const resultIndex = this.resultsToBePublished.indexOf(testAlias)
246
+ if (resultIndex !== -1) {
247
+ this.resultsToBePublished.splice(resultIndex, 1)
248
+ }
249
+ }
250
+
251
+ private async getTestPointIdsByTCIds (planId: number, testcaseIds: number[]): Promise<number[] | void> {
252
+ try {
253
+ const pointsQuery: TestInterfaces.TestPointsQuery = {
254
+ pointsFilter: { testcaseIds }
255
+ }
256
+ const pointsQueryResult: TestInterfaces.TestPointsQuery = await this.testApi.getPointsByQuery(
257
+ pointsQuery,
258
+ this.projectName
259
+ )
260
+ const pointsIds: number[] = []
261
+ if (pointsQueryResult.points) {
262
+ pointsQueryResult.points.forEach((point: TestPoint) => {
263
+ if (point.testPlan && point.testPlan.id && parseInt(point.testPlan.id, 10) === planId) {
264
+ pointsIds.push(point.id)
265
+ }
266
+ })
267
+ }
268
+ return pointsIds
269
+ } catch (e) {
270
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
271
+ console.error(`While getting test points ids, by test cases ids. Error: ${e}`)
272
+ }
273
+ }
274
+
275
+ private addReportingOverride = (api: Test.ITestApi): Test.ITestApi => {
276
+ api.addTestResultsToTestRun = function (results, projectName, runId) {
277
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
278
+ return new Promise(async (resolve, reject) => {
279
+ const routeValues = {
280
+ project: projectName,
281
+ runId
282
+ }
283
+
284
+ try {
285
+ const verData = await this.vsoClient.getVersioningData(
286
+ '5.0-preview.5',
287
+ 'Test',
288
+ '4637d869-3a76-4468-8057-0bb02aa385cf',
289
+ routeValues
290
+ )
291
+
292
+ const url = verData.requestUrl
293
+ const options = this.createRequestOptions('application/json', verData.apiVersion)
294
+ const res = await this.rest.create(url as string, results, options)
295
+ resolve(res as any)
296
+ } catch (err) {
297
+ reject(err)
298
+ }
299
+ })
300
+ }
301
+ return api
302
+ };
303
+
304
+ private getBase64 (filePath: string): string {
305
+ return readFileSync(filePath, { encoding: 'base64' })
306
+ }
307
+
308
+ private async uploadAttachments (testResult: TestResult, caseId: number): Promise<string[]> {
309
+ this.log(chalk`{gray Start upload attachments for test case [${caseId}]}`)
310
+ return await Promise.all(
311
+ testResult.attachments.map(async (attachment) => {
312
+ const attachments: TestInterfaces.TestAttachmentRequestModel = {
313
+ attachmentType: 'GeneralAttachment',
314
+ fileName: attachment?.name + '.png',
315
+ stream: this.getBase64(attachment.path as string)
316
+ }
317
+
318
+ const response = await this.testApi.createTestResultAttachment(
319
+ attachments,
320
+ this.projectName,
321
+ this.runId!,
322
+ caseId
323
+ )
324
+ return response.url
325
+ })
326
+ )
327
+ }
328
+
329
+ private async publishCaseResult (test: TestCase, testResult: TestResult): Promise<void> {
330
+ this.logTestItem(test, testResult)
331
+ const caseId = this.getCaseIds(test)
332
+ if (caseId === '') {
333
+ return
334
+ }
335
+
336
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
337
+ return new Promise(async (resolved, reject) => {
338
+ const testAlias = `${caseId} - ${test.title}`
339
+ this.resultsToBePublished.push(testAlias)
340
+ this.log(chalk`{gray Start publishing: ${test.title}}`)
341
+ try {
342
+ while (!this.runId) {
343
+ // need wait runId variable to be initialised in onBegin() hook
344
+ await new Promise((resolve) => setTimeout(resolve, 50))
345
+ }
346
+
347
+ const pointIds = await this.getTestPointIdsByTCIds(this.planId as number, [parseInt(caseId, 10)])
348
+ const results: TestInterfaces.TestCaseResult[] = [
349
+ {
350
+ testCase: { id: caseId },
351
+ testPoint: { id: (pointIds as number[])[0].toString() },
352
+ testCaseTitle: test.title,
353
+ outcome: Statuses[testResult.status],
354
+ state: 'Completed',
355
+ durationInMs: testResult.duration,
356
+ errorMessage: testResult.error
357
+ ? `${test.title}: ${testResult.error?.message?.replace(/\u001b\[.*?m/g, '') as string}`
358
+ : undefined,
359
+ stackTrace: testResult.error?.stack?.replace(/\u001b\[.*?m/g, '')
360
+ }
361
+ ]
362
+
363
+ const testCaseResult: TestResultsToTestRun = await this.addReportingOverride(this.testApi).addTestResultsToTestRun(results, this.projectName, this.runId) as unknown as TestResultsToTestRun
364
+ if (this.options.uploadAttachments && testResult.attachments.length > 0) {
365
+ await this.uploadAttachments(testResult, testCaseResult.result.value![0].id)
366
+ }
367
+
368
+ this.removePublished(testAlias)
369
+ this.publishedResultsCount++
370
+ this.log(chalk`{gray Result published: ${test.title}}`)
371
+ resolved(testCaseResult)
372
+ } catch (err) {
373
+ this.removePublished(testAlias)
374
+ this.log(chalk`{red ${err}}`)
375
+ reject(err)
376
+ }
377
+ }).then(alwaysUndefined)
378
+ }
379
+ }
380
+
381
+ export default PlaywrightReporter
@@ -0,0 +1,20 @@
1
+ import { expect, test } from '@playwright/test'
2
+
3
+ test.beforeEach(async ({ page }) => {
4
+ await page.goto('https://playwright.dev/')
5
+ })
6
+
7
+ test.describe('Describe', () => {
8
+ test('[3] Should page opened', async ({ page }) => {
9
+ await page.locator('text=Get started').click()
10
+ await expect(page).toHaveTitle(/Getting started/)
11
+ })
12
+ test('[7] Should page closed', async ({ page }) => {
13
+ await page.locator('text=Get started').click()
14
+ await expect(page).toHaveTitle(/Getting started/)
15
+ })
16
+ test('[8] Awaiting for user input', async ({ page }) => {
17
+ await page.locator('text=Get started').click()
18
+ await expect(page).toHaveTitle(/Getting started/)
19
+ })
20
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic Options */
4
+ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5
+ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6
+ "lib": ["es2020", "dom"], /* Specify library files to be included in the compilation. */
7
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
8
+ "declarationDir": "./dist", /* Output directory for generated declaration files. */
9
+ "sourceMap": true, /* Generates corresponding '.map' file. */
10
+ "outDir": "./dist/", /* Redirect output structure to the directory. */
11
+ /* Strict Type-Checking Options */
12
+ "strict": true, /* Enable all strict type-checking options. */
13
+ "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
14
+ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
15
+ "types": ["node"]
16
+ },
17
+ "exclude": [
18
+ "node_modules",
19
+ "dist",
20
+ "demo",
21
+ "**/**.test.ts",
22
+ "**/**.spec.ts",
23
+ "**/playwright.config.ts",
24
+ "**/webpack.config.ts"
25
+ ],
26
+ "compilation": {
27
+ "compiler": {
28
+ "context": "./src",
29
+ "outputPath": "./dist"
30
+ }
31
+ }
32
+ }