@serenity-js/playwright-test 3.2.1 → 3.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.3.1](https://github.com/serenity-js/serenity-js/compare/v3.3.0...v3.3.1) (2023-06-08)
7
+
8
+ **Note:** Version bump only for package @serenity-js/playwright-test
9
+
10
+
11
+
12
+
13
+
14
+ # [3.3.0](https://github.com/serenity-js/serenity-js/compare/v3.2.1...v3.3.0) (2023-06-01)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **playwright-test:** corrected synchronisation of the `platform` fixture ([7156f84](https://github.com/serenity-js/serenity-js/commit/7156f840dc8fe5688d25aca5ba87d925158e9c7d)), closes [#1717](https://github.com/serenity-js/serenity-js/issues/1717)
20
+ * **playwright:** support for Playwright 1.34.0 ([5d591c7](https://github.com/serenity-js/serenity-js/commit/5d591c71e89ac4cfd41b8f7e3a1c9017f962d9e3))
21
+ * **playwright:** updated Playwright to 1.34.2 ([c944031](https://github.com/serenity-js/serenity-js/commit/c94403199a349d59bb777b981897039c102f243f))
22
+ * **playwright:** upgraded to Playwright 1.34.3 ([0ded19e](https://github.com/serenity-js/serenity-js/commit/0ded19e8ef3aea74307ab3bbd69ff5f7b3c9f78b))
23
+
24
+
25
+ ### Features
26
+
27
+ * **playwright-test:** improved integration with Playwright Test ([45b324f](https://github.com/serenity-js/serenity-js/commit/45b324f4b2e2992dc2df78c18013f2f235ff91b9)), closes [#1717](https://github.com/serenity-js/serenity-js/issues/1717)
28
+ * **playwright-test:** much more detailed Playwright Test reports ([5980a1e](https://github.com/serenity-js/serenity-js/commit/5980a1e37047d71199cc169271fa11869e98355b)), closes [#1717](https://github.com/serenity-js/serenity-js/issues/1717)
29
+
30
+
31
+
32
+
33
+
6
34
  ## [3.2.1](https://github.com/serenity-js/serenity-js/compare/v3.2.0...v3.2.1) (2023-05-15)
7
35
 
8
36
  **Note:** Version bump only for package @serenity-js/playwright-test
@@ -0,0 +1,13 @@
1
+ import type { test as base } from '@playwright/test';
2
+ import { Activity, PerformActivities, PerformsActivities } from '@serenity-js/core';
3
+ import { EmitsDomainEvents } from '@serenity-js/core/lib/events';
4
+ export declare class PerformActivitiesAsPlaywrightSteps extends PerformActivities {
5
+ private readonly test;
6
+ constructor(actor: PerformsActivities & {
7
+ name: string;
8
+ }, stage: EmitsDomainEvents, test: typeof base);
9
+ perform(activity: Activity): Promise<void>;
10
+ private parametersOf;
11
+ private locationOf;
12
+ }
13
+ //# sourceMappingURL=PerformActivitiesAsPlaywrightSteps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PerformActivitiesAsPlaywrightSteps.d.ts","sourceRoot":"","sources":["../../src/api/PerformActivitiesAsPlaywrightSteps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAkB,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,qBAAa,kCAAmC,SAAQ,iBAAiB;IAKjE,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFrB,KAAK,EAAE,kBAAkB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAC5C,KAAK,EAAE,iBAAiB,EACP,IAAI,EAAE,OAAO,IAAI;IAKvB,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,UAAU;CAQrB"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerformActivitiesAsPlaywrightSteps = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const objects_1 = require("tiny-types/lib/objects");
6
+ class PerformActivitiesAsPlaywrightSteps extends core_1.PerformActivities {
7
+ constructor(actor, stage, test) {
8
+ super(actor, stage);
9
+ this.test = test;
10
+ }
11
+ async perform(activity) {
12
+ const testInfo = this.test.info();
13
+ // see https://github.com/microsoft/playwright/issues/23157
14
+ const runAsStep = (testInfo['_runAsStep']).bind(testInfo);
15
+ return runAsStep({
16
+ category: 'test.step',
17
+ title: this.nameOf(activity),
18
+ location: this.locationOf(activity),
19
+ params: this.parametersOf(activity),
20
+ }, async (step_) => {
21
+ await super.perform(activity);
22
+ });
23
+ }
24
+ parametersOf(activity) {
25
+ if (activity instanceof core_1.Interaction) {
26
+ return (0, objects_1.significantFieldsOf)(activity).reduce((acc, field) => {
27
+ acc[field] = (0, core_1.d) `${activity[field]}`;
28
+ return acc;
29
+ }, {});
30
+ }
31
+ return {};
32
+ }
33
+ locationOf(activity) {
34
+ const instantiationLocation = activity.instantiationLocation();
35
+ return {
36
+ file: instantiationLocation.path.value,
37
+ line: instantiationLocation.line,
38
+ column: instantiationLocation.column
39
+ };
40
+ }
41
+ }
42
+ exports.PerformActivitiesAsPlaywrightSteps = PerformActivitiesAsPlaywrightSteps;
43
+ //# sourceMappingURL=PerformActivitiesAsPlaywrightSteps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PerformActivitiesAsPlaywrightSteps.js","sourceRoot":"","sources":["../../src/api/PerformActivitiesAsPlaywrightSteps.ts"],"names":[],"mappings":";;;AACA,4CAAoG;AAEpG,oDAA6D;AAE7D,MAAa,kCAAmC,SAAQ,wBAAiB;IAErE,YACI,KAA4C,EAC5C,KAAwB,EACP,IAAiB;QAElC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAFH,SAAI,GAAJ,IAAI,CAAa;IAGtC,CAAC;IAEQ,KAAK,CAAC,OAAO,CAAC,QAAkB;QACrC,MAAM,QAAQ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AACxE,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAgB,CAAC;AACrE,eAAO,MAAM,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAe,CAAC;AAClE,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAa,CAAC"}
@@ -33,6 +33,7 @@ const web_1 = require("@serenity-js/web");
33
33
  const os = __importStar(require("os"));
34
34
  const tiny_types_1 = require("tiny-types");
35
35
  const reporter_1 = require("../reporter");
36
+ const PerformActivitiesAsPlaywrightSteps_1 = require("./PerformActivitiesAsPlaywrightSteps");
36
37
  /**
37
38
  * Declares a single test scenario.
38
39
  *
@@ -92,7 +93,9 @@ const reporter_1 = require("../reporter");
92
93
  */
93
94
  exports.it = test_1.test.extend({
94
95
  actors: [
95
- ({ browser, contextOptions }, use) => use(core_1.Cast.where(actor => actor.whoCan(playwright_1.BrowseTheWebWithPlaywright.using(browser, contextOptions), core_1.TakeNotes.usingAnEmptyNotepad()))),
96
+ async ({ browser, contextOptions, serenity }, use) => {
97
+ await use(core_1.Cast.where(actor => actor.whoCan(new PerformActivitiesAsPlaywrightSteps_1.PerformActivitiesAsPlaywrightSteps(actor, serenity, exports.it), playwright_1.BrowseTheWebWithPlaywright.using(browser, contextOptions), core_1.TakeNotes.usingAnEmptyNotepad())));
98
+ },
96
99
  { option: true },
97
100
  ],
98
101
  defaultActorName: [
@@ -114,13 +117,13 @@ exports.it = test_1.test.extend({
114
117
  { option: true },
115
118
  ],
116
119
  // eslint-disable-next-line no-empty-pattern
117
- platform: ({}, use) => {
120
+ platform: async ({}, use) => {
118
121
  const platform = os.platform();
119
122
  // https://nodejs.org/api/process.html#process_process_platform
120
123
  const name = platform === 'win32'
121
124
  ? 'Windows'
122
125
  : (platform === 'darwin' ? 'macOS' : 'Linux');
123
- use({ name, version: os.release() });
126
+ await use({ name, version: os.release() });
124
127
  },
125
128
  serenity: async ({ crew, cueTimeout, interactionTimeout, platform }, use, info) => {
126
129
  const domainEventBuffer = new reporter_1.DomainEventBuffer();
@@ -1 +1 @@
1
- {"version":3,"file":"test-api.js","sourceRoot":"","sources":["../../src/api/test-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0D;AAC1D,4CAA+G;AAC/G,yDAA0E;AAC1E,uDAAsE;AACtE,wDAAqF;AACrF,0CAAsE;AACtE,uCAAyB;AACzB,2CAAqE;AAErE,0CAA2H;AAK3H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACU,QAAA,EAAE,GAAqB,WAAI,CAAC,MAAM,CAAqD;IAEhG,MAAM,EAAE;QACJ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,EAAE,CACjC,GAAG,CAAC,WAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAChC,uCAA0B,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,EACzD,gBAAS,CAAC,mBAAmB,EAAE,CAClC,CAAC,CAAC;QACP,EAAE,MAAM,EAAE,IAAI,EAAE;KACnB;IAED,gBAAgB,EAAE;QACd,QAAQ;QACR,EAAE,MAAM,EAAE,IAAI,EAAE;KACnB;IAED,UAAU,EAAE;QACR,eAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACrB,EAAE,MAAM,EAAE,IAAI,EAAE;KACnB;IAED,kBAAkB,EAAE;QAChB,eAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACrB,EAAE,MAAM,EAAE,IAAI,EAAE;KACnB;IAED,IAAI,EAAE;QACF;YACI,kBAAY,CAAC,OAAO,CAAC,0BAAoB,CAAC;SAC7C;QACD,EAAE,MAAM,EAAE,IAAI,EAAE;KACnB;IAED,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ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class PlaywrightStepReporter implements StageCrewMember {
5
5
  private readonly testInfo;
6
6
  private stage?;
7
- private readonly steps;
8
7
  constructor(testInfo: TestInfo, stage?: Stage);
9
8
  assignedTo(stage: Stage): StageCrewMember;
10
9
  notifyOf(event: DomainEvent): void;
11
- private isAPhotoAttempt;
12
- private indicatesCompletionOfAnAsyncOperation;
13
10
  private attachPhotoFrom;
14
- private createStep;
11
+ private shouldAddTag;
12
+ private addTag;
15
13
  }
16
14
  //# sourceMappingURL=PlaywrightStepReporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlaywrightStepReporter.d.ts","sourceRoot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAOH,WAAW,EAId,MAAM,8BAA8B,CAAC;AAoBtC,qBAAa,sBAAuB,YAAW,eAAe;IAKtD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,KAAK,CAAC;IAJlB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAG7C,QAAQ,EAAE,QAAQ,EAC3B,KAAK,CAAC,EAAE,KAAK;IAIzB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe;IAMzC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IA8ClC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,qCAAqC;IAM7C,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,UAAU;CAYrB"}
1
+ {"version":3,"file":"PlaywrightStepReporter.d.ts","sourceRoot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAIH,WAAW,EAEd,MAAM,8BAA8B,CAAC;AAItC,qBAAa,sBAAuB,YAAW,eAAe;IAGtD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,KAAK,CAAC;gBADG,QAAQ,EAAE,QAAQ,EAC3B,KAAK,CAAC,EAAE,KAAK;IAIzB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe;IAMzC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAWlC,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,MAAM;CAGjB"}
@@ -2,67 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlaywrightStepReporter = void 0;
4
4
  const events_1 = require("@serenity-js/core/lib/events");
5
- const io_1 = require("@serenity-js/core/lib/io");
6
5
  const model_1 = require("@serenity-js/core/lib/model");
7
- const web_1 = require("@serenity-js/web");
8
- const tiny_types_1 = require("tiny-types");
9
- const genericPathToPhotographer = io_1.Path.from(require.resolve('@serenity-js/web'));
10
6
  class PlaywrightStepReporter {
11
7
  constructor(testInfo, stage) {
12
8
  this.testInfo = testInfo;
13
9
  this.stage = stage;
14
- this.steps = new Map();
15
10
  }
16
11
  assignedTo(stage) {
17
12
  this.stage = stage;
18
13
  return this;
19
14
  }
20
15
  notifyOf(event) {
21
- (0, tiny_types_1.match)(event)
22
- .when(events_1.TaskStarts, (e) => {
23
- this.steps.set(e.activityId.value, this.createStep(e.details, 'task'));
24
- })
25
- .when(events_1.InteractionStarts, (e) => {
26
- this.steps.set(e.activityId.value, this.createStep(e.details, 'interaction'));
27
- })
28
- .when(events_1.AsyncOperationAttempted, (e) => {
29
- if (this.isAPhotoAttempt(e)) {
30
- this.steps.set(e.correlationId.value, this.createStep(new model_1.ActivityDetails(new model_1.Name(`${web_1.Photographer.name}: ${e.description.value}`), new io_1.FileSystemLocation(genericPathToPhotographer)), 'crew'));
31
- }
32
- })
33
- .when(events_1.ActivityFinished, (e) => {
34
- const error = e.outcome instanceof model_1.ProblemIndication
35
- ? e.outcome.error
36
- : undefined;
37
- this.steps.get(e.activityId.value).complete({ error });
38
- })
39
- .when(events_1.ActivityRelatedArtifactGenerated, (e) => {
40
- if (e.artifact instanceof model_1.Photo) {
41
- this.attachPhotoFrom(e);
42
- }
43
- })
44
- .when(events_1.SceneTagged, (e) => {
45
- // don't include platform and browser tags as Playwright already includes them
46
- if (!(e.tag instanceof model_1.PlatformTag || e.tag instanceof model_1.BrowserTag)) {
47
- this.testInfo.annotations.push({ type: e.tag.type, description: e.tag.name });
48
- }
49
- })
50
- .else(e => {
51
- if (this.indicatesCompletionOfAnAsyncOperation(e) && this.steps.has(e.correlationId.value)) {
52
- const error = event instanceof events_1.AsyncOperationFailed
53
- ? event.error
54
- : undefined;
55
- this.steps.get(e.correlationId.value).complete({ error });
56
- }
57
- });
58
- }
59
- isAPhotoAttempt(event) {
60
- return event.name.value.startsWith(web_1.Photographer.name);
61
- }
62
- indicatesCompletionOfAnAsyncOperation(event) {
63
- return event instanceof events_1.AsyncOperationCompleted
64
- || event instanceof events_1.AsyncOperationAborted
65
- || event instanceof events_1.AsyncOperationFailed;
16
+ if (event instanceof events_1.ActivityRelatedArtifactGenerated && event.artifact instanceof model_1.Photo) {
17
+ this.attachPhotoFrom(event);
18
+ }
19
+ if (event instanceof events_1.SceneTagged && this.shouldAddTag(event.tag)) {
20
+ this.addTag(event.tag);
21
+ }
66
22
  }
67
23
  attachPhotoFrom(event) {
68
24
  const id = model_1.CorrelationId.create();
@@ -72,17 +28,12 @@ class PlaywrightStepReporter {
72
28
  this.stage.announce(new events_1.AsyncOperationCompleted(id, this.stage.currentTime()));
73
29
  });
74
30
  }
75
- createStep(activityDetails, type) {
76
- // https://github.com/microsoft/playwright/blob/04f77f231981780704a3a5e2cea93e3c420809a0/packages/playwright-test/src/expect.ts#L200-L206
77
- return this.testInfo._addStep({
78
- location: activityDetails.location
79
- ? { file: activityDetails.location.path.value, line: activityDetails.location.line, column: activityDetails.location.column }
80
- : undefined,
81
- category: `serenity-js:${type}`,
82
- title: activityDetails.name.value,
83
- canHaveChildren: true,
84
- forceNoParent: false,
85
- });
31
+ shouldAddTag(tag) {
32
+ // don't include platform and browser tags as Playwright already includes them
33
+ return !(tag instanceof model_1.PlatformTag || tag instanceof model_1.BrowserTag);
34
+ }
35
+ addTag(tag) {
36
+ this.testInfo.annotations.push({ type: tag.type, description: tag.name });
86
37
  }
87
38
  }
88
39
  exports.PlaywrightStepReporter = PlaywrightStepReporter;
@@ -1 +1 @@
1
- {"version":3,"file":"PlaywrightStepReporter.js","sourceRoot":"","sources":["../../src/reporter/PlaywrightStepReporter.ts"],"names":[],"mappings":";;;AAGA,yDAWsC;AACtC,iDAAoE;AACpE,uDAAmJ;AACnJ,0CAAgD;AAChD,2CAAmC;AAEnC,MAAM,yBAAyB,GAAG,SAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAchF,MAAa,sBAAsB;IAI/B,YACqB,QAAkB,EAC3B,KAAa;QADJ,aAAQ,GAAR,QAAQ,CAAU;QAC3B,UAAK,GAAL,KAAK,CAAQ;QAJR,UAAK,GAAkC,IAAI,GAAG,EAAE,CAAC;IAMlE,CAAC;IAED,UAAU,CAAC,KAAY;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,KAAkB;QAEvB,IAAA,kBAAK,EAAoB,KAAK,CAAC;aAC1B,IAAI,CAAC,mBAAU,EAAE,CAAC,CAAa,EAAE,EAAE;YAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;QAC1E,CAAC,CAAC;aACD,IAAI,C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AAW,EAAE,CAC3B,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACX,CAAC;IAEO,YAAY,CAAC,GAAQ;QACzB,8EAA8E;QAC9E,OAAO,CAAE,CAAC,GAAG,YAAY,mBAAW,IAAI,GAAG,YAAY,kBAAU,CAAC,CAAA;IACtE,CAAC;IAEO,MAAM,CAAC,GAAQ;QACnB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;CACJ;AApDD,wDAoDC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-js/playwright-test",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "description": "Serenity/JS reporter and test APIs for Playwright Test",
5
5
  "author": {
6
6
  "name": "Jan Molak",
@@ -44,10 +44,10 @@
44
44
  "node": "^16.13 || ^18.12 || ^20"
45
45
  },
46
46
  "dependencies": {
47
- "@playwright/test": "^1.33.0",
48
- "@serenity-js/core": "3.2.1",
49
- "@serenity-js/playwright": "3.2.1",
50
- "@serenity-js/web": "3.2.1",
47
+ "@playwright/test": "^1.34.3",
48
+ "@serenity-js/core": "3.3.1",
49
+ "@serenity-js/playwright": "3.3.1",
50
+ "@serenity-js/web": "3.3.1",
51
51
  "deepmerge": "^4.3.1",
52
52
  "tiny-types": "^1.19.1"
53
53
  },
@@ -55,11 +55,11 @@
55
55
  "@integration/testing-tools": "3.0.0",
56
56
  "@types/chai": "^4.3.5",
57
57
  "@types/mocha": "^10.0.1",
58
- "c8": "7.13.0",
58
+ "c8": "7.14.0",
59
59
  "mocha": "^10.2.0",
60
60
  "mocha-multi": "^1.1.7",
61
61
  "ts-node": "^10.9.1",
62
62
  "typescript": "^5.0.4"
63
63
  },
64
- "gitHead": "9a5a77e6e966c827c0331699bef34326905c16b6"
64
+ "gitHead": "d036ce75c1eb131d3cde28b04e668dc24f959e2f"
65
65
  }
@@ -0,0 +1,63 @@
1
+ import type { test as base } from '@playwright/test';
2
+ import { Activity, d, Interaction, PerformActivities, PerformsActivities } from '@serenity-js/core';
3
+ import { EmitsDomainEvents } from '@serenity-js/core/lib/events';
4
+ import { significantFieldsOf } from 'tiny-types/lib/objects';
5
+
6
+ export class PerformActivitiesAsPlaywrightSteps extends PerformActivities {
7
+
8
+ constructor(
9
+ actor: PerformsActivities & { name: string },
10
+ stage: EmitsDomainEvents,
11
+ private readonly test: typeof base,
12
+ ) {
13
+ super(actor, stage);
14
+ }
15
+
16
+ override async perform(activity: Activity): Promise<void> {
17
+ const testInfo = this.test.info();
18
+
19
+ // see https://github.com/microsoft/playwright/issues/23157
20
+ const runAsStep = (testInfo['_runAsStep']).bind(testInfo) as <T>(stepInfo: TestStepInternal, callback: (step: TestStepInternal) => Promise<T>) => Promise<T>;
21
+
22
+ return runAsStep({
23
+ category: 'test.step',
24
+ title: this.nameOf(activity),
25
+ location: this.locationOf(activity),
26
+ params: this.parametersOf(activity),
27
+ }, async step_ => {
28
+ await super.perform(activity)
29
+ })
30
+ }
31
+
32
+ private parametersOf(activity: Activity): Record<string, any> {
33
+ if (activity instanceof Interaction) {
34
+ return significantFieldsOf(activity).reduce((acc, field) => {
35
+ acc[field] = d`${ activity[field] }`;
36
+ return acc;
37
+ }, {});
38
+ }
39
+ return {};
40
+ }
41
+
42
+ private locationOf(activity: Activity): { column: number, file: string, line: number } {
43
+ const instantiationLocation = activity.instantiationLocation();
44
+ return {
45
+ file: instantiationLocation.path.value,
46
+ line: instantiationLocation.line,
47
+ column: instantiationLocation.column
48
+ };
49
+ }
50
+ }
51
+
52
+ interface TestStepInternal {
53
+ title: string;
54
+ category: string;
55
+ location?: {
56
+ column: number;
57
+ file: string;
58
+ line: number;
59
+ };
60
+ laxParent?: boolean;
61
+ apiName?: string;
62
+ params?: Record<string, any>;
63
+ }
@@ -8,6 +8,7 @@ import * as os from 'os';
8
8
  import { ensure, isFunction, JSONValue, property } from 'tiny-types';
9
9
 
10
10
  import { DomainEventBuffer, PlaywrightStepReporter, SERENITY_JS_DOMAIN_EVENTS_ATTACHMENT_CONTENT_TYPE } from '../reporter';
11
+ import { PerformActivitiesAsPlaywrightSteps } from './PerformActivitiesAsPlaywrightSteps';
11
12
  import { SerenityFixtures } from './SerenityFixtures';
12
13
  import { SerenityOptions } from './SerenityOptions';
13
14
  import { SerenityTestType } from './SerenityTestType';
@@ -72,11 +73,14 @@ import { SerenityTestType } from './SerenityTestType';
72
73
  export const it: SerenityTestType = base.extend<Omit<SerenityOptions, 'actors'> & SerenityFixtures>({
73
74
 
74
75
  actors: [
75
- ({ browser, contextOptions }, use) =>
76
- use(Cast.where(actor => actor.whoCan(
76
+ async ({ browser, contextOptions, serenity }, use) => {
77
+
78
+ await use(Cast.where(actor => actor.whoCan(
79
+ new PerformActivitiesAsPlaywrightSteps(actor, serenity, it),
77
80
  BrowseTheWebWithPlaywright.using(browser, contextOptions),
78
81
  TakeNotes.usingAnEmptyNotepad(),
79
- ))),
82
+ )))
83
+ },
80
84
  { option: true },
81
85
  ],
82
86
 
@@ -103,7 +107,7 @@ export const it: SerenityTestType = base.extend<Omit<SerenityOptions, 'actors'>
103
107
  ],
104
108
 
105
109
  // eslint-disable-next-line no-empty-pattern
106
- platform: ({}, use) => {
110
+ platform: async ({}, use) => {
107
111
  const platform = os.platform();
108
112
 
109
113
  // https://nodejs.org/api/process.html#process_process_platform
@@ -111,7 +115,7 @@ export const it: SerenityTestType = base.extend<Omit<SerenityOptions, 'actors'>
111
115
  ? 'Windows'
112
116
  : (platform === 'darwin' ? 'macOS' : 'Linux');
113
117
 
114
- use({ name, version: os.release() });
118
+ await use({ name, version: os.release() });
115
119
  },
116
120
 
117
121
  serenity: async ({ crew, cueTimeout, interactionTimeout, platform }, use, info: TestInfo) => {
@@ -1,41 +1,17 @@
1
1
  import { TestInfo } from '@playwright/test';
2
- import { Location, TestError } from '@playwright/test/reporter';
3
2
  import { Stage, StageCrewMember } from '@serenity-js/core';
4
3
  import {
5
- ActivityFinished,
6
4
  ActivityRelatedArtifactGenerated,
7
- AsyncOperationAborted,
8
5
  AsyncOperationAttempted,
9
6
  AsyncOperationCompleted,
10
- AsyncOperationFailed,
11
7
  DomainEvent,
12
- InteractionStarts,
13
8
  SceneTagged,
14
- TaskStarts,
15
9
  } from '@serenity-js/core/lib/events';
16
- import { FileSystemLocation, Path } from '@serenity-js/core/lib/io';
17
- import { ActivityDetails, BrowserTag, CorrelationId, Description, Name, Photo, PlatformTag, ProblemIndication } from '@serenity-js/core/lib/model';
18
- import { Photographer } from '@serenity-js/web';
19
- import { match } from 'tiny-types';
20
-
21
- const genericPathToPhotographer = Path.from(require.resolve('@serenity-js/web'))
22
-
23
- // https://github.com/microsoft/playwright/blob/04f77f231981780704a3a5e2cea93e3c420809a0/packages/playwright-test/src/types.ts#L30
24
- interface TestStepInternal {
25
- complete(result: { error?: Error | TestError }): void;
26
-
27
- title: string;
28
- category: string;
29
- canHaveChildren: boolean;
30
- forceNoParent: boolean;
31
- location?: Location;
32
- refinedTitle?: string;
33
- }
10
+ import { BrowserTag, CorrelationId, Description, Name, Photo, PlatformTag } from '@serenity-js/core/lib/model';
11
+ import { Tag } from '@serenity-js/core/src/model';
34
12
 
35
13
  export class PlaywrightStepReporter implements StageCrewMember {
36
14
 
37
- private readonly steps: Map<string, TestStepInternal> = new Map();
38
-
39
15
  constructor(
40
16
  private readonly testInfo: TestInfo,
41
17
  private stage?: Stage,
@@ -50,58 +26,13 @@ export class PlaywrightStepReporter implements StageCrewMember {
50
26
 
51
27
  notifyOf(event: DomainEvent): void {
52
28
 
53
- match<DomainEvent, void>(event)
54
- .when(TaskStarts, (e: TaskStarts) => {
55
- this.steps.set(e.activityId.value, this.createStep(e.details, 'task'))
56
- })
57
- .when(InteractionStarts, (e: InteractionStarts) => {
58
- this.steps.set(e.activityId.value, this.createStep(e.details, 'interaction'));
59
- })
60
- .when(AsyncOperationAttempted, (e: AsyncOperationAttempted) => {
61
- if (this.isAPhotoAttempt(e)) {
62
- this.steps.set(e.correlationId.value, this.createStep(new ActivityDetails(
63
- new Name(`${ Photographer.name }: ${ e.description.value }`),
64
- new FileSystemLocation(genericPathToPhotographer)
65
- ), 'crew'));
66
- }
67
- })
68
- .when(ActivityFinished, (e: ActivityFinished) => {
69
- const error = e.outcome instanceof ProblemIndication
70
- ? e.outcome.error
71
- : undefined;
72
-
73
- this.steps.get(e.activityId.value).complete({ error });
74
- })
75
- .when(ActivityRelatedArtifactGenerated, (e: ActivityRelatedArtifactGenerated) => {
76
- if (e.artifact instanceof Photo) {
77
- this.attachPhotoFrom(e);
78
- }
79
- })
80
- .when(SceneTagged, (e: SceneTagged) => {
81
- // don't include platform and browser tags as Playwright already includes them
82
- if (! (e.tag instanceof PlatformTag || e.tag instanceof BrowserTag)) {
83
- this.testInfo.annotations.push({ type: e.tag.type, description: e.tag.name });
84
- }
85
- })
86
- .else(e => {
87
- if (this.indicatesCompletionOfAnAsyncOperation(e) && this.steps.has(e.correlationId.value)) {
88
- const error = event instanceof AsyncOperationFailed
89
- ? event.error
90
- : undefined;
29
+ if (event instanceof ActivityRelatedArtifactGenerated && event.artifact instanceof Photo) {
30
+ this.attachPhotoFrom(event);
31
+ }
91
32
 
92
- this.steps.get(e.correlationId.value).complete({ error })
93
- }
94
- })
95
- }
96
-
97
- private isAPhotoAttempt(event: AsyncOperationAttempted): event is AsyncOperationAttempted {
98
- return event.name.value.startsWith(Photographer.name);
99
- }
100
-
101
- private indicatesCompletionOfAnAsyncOperation(event: DomainEvent): event is AsyncOperationCompleted | AsyncOperationAborted | AsyncOperationFailed {
102
- return event instanceof AsyncOperationCompleted
103
- || event instanceof AsyncOperationAborted
104
- || event instanceof AsyncOperationFailed
33
+ if (event instanceof SceneTagged && this.shouldAddTag(event.tag)) {
34
+ this.addTag(event.tag);
35
+ }
105
36
  }
106
37
 
107
38
  private attachPhotoFrom(event: ActivityRelatedArtifactGenerated) {
@@ -123,16 +54,12 @@ export class PlaywrightStepReporter implements StageCrewMember {
123
54
  });
124
55
  }
125
56
 
126
- private createStep(activityDetails: ActivityDetails, type: 'task' | 'interaction' | 'crew'): TestStepInternal {
127
- // https://github.com/microsoft/playwright/blob/04f77f231981780704a3a5e2cea93e3c420809a0/packages/playwright-test/src/expect.ts#L200-L206
128
- return (this.testInfo as any)._addStep({
129
- location: activityDetails.location
130
- ? { file: activityDetails.location.path.value, line: activityDetails.location.line, column: activityDetails.location.column }
131
- : undefined,
132
- category: `serenity-js:${ type }`,
133
- title: activityDetails.name.value,
134
- canHaveChildren: true,
135
- forceNoParent: false,
136
- }) as TestStepInternal;
57
+ private shouldAddTag(tag: Tag): boolean {
58
+ // don't include platform and browser tags as Playwright already includes them
59
+ return ! (tag instanceof PlatformTag || tag instanceof BrowserTag)
60
+ }
61
+
62
+ private addTag(tag: Tag): void {
63
+ this.testInfo.annotations.push({ type: tag.type, description: tag.name });
137
64
  }
138
65
  }