@serenity-js/playwright-test 3.0.0-rc.28
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 +24 -0
- package/LICENSE.md +201 -0
- package/NOTICE.md +1 -0
- package/README.md +285 -0
- package/lib/PlaywrightTestConfig.d.ts +8 -0
- package/lib/PlaywrightTestConfig.d.ts.map +1 -0
- package/lib/PlaywrightTestConfig.js +3 -0
- package/lib/PlaywrightTestConfig.js.map +1 -0
- package/lib/api.d.ts +25 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +97 -0
- package/lib/api.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/reporter/DomainEventBuffer.d.ts +11 -0
- package/lib/reporter/DomainEventBuffer.d.ts.map +1 -0
- package/lib/reporter/DomainEventBuffer.js +23 -0
- package/lib/reporter/DomainEventBuffer.js.map +1 -0
- package/lib/reporter/PlaywrightAttachments.d.ts +2 -0
- package/lib/reporter/PlaywrightAttachments.d.ts.map +1 -0
- package/lib/reporter/PlaywrightAttachments.js +5 -0
- package/lib/reporter/PlaywrightAttachments.js.map +1 -0
- package/lib/reporter/PlaywrightStepReporter.d.ts +13 -0
- package/lib/reporter/PlaywrightStepReporter.d.ts.map +1 -0
- package/lib/reporter/PlaywrightStepReporter.js +46 -0
- package/lib/reporter/PlaywrightStepReporter.js.map +1 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +46 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.js +174 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.js.map +1 -0
- package/lib/reporter/index.d.ts +5 -0
- package/lib/reporter/index.d.ts.map +1 -0
- package/lib/reporter/index.js +21 -0
- package/lib/reporter/index.js.map +1 -0
- package/package.json +65 -0
- package/src/PlaywrightTestConfig.ts +6 -0
- package/src/api.ts +121 -0
- package/src/index.ts +3 -0
- package/src/reporter/DomainEventBuffer.ts +28 -0
- package/src/reporter/PlaywrightAttachments.ts +1 -0
- package/src/reporter/PlaywrightStepReporter.ts +83 -0
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +279 -0
- package/src/reporter/index.ts +4 -0
- package/tsconfig.build.json +14 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [3.0.0-rc.28](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.27...v3.0.0-rc.28) (2022-09-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** activity is now able to detect invocation location on Node 14 ([41f4776](https://github.com/serenity-js/serenity-js/commit/41f4776736620bc32d474d9b66f69c742f8eca96)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
12
|
+
* **playwright-test:** bulk-attach all Serenity/JS events to Playwright report ([a5f3d7c](https://github.com/serenity-js/serenity-js/commit/a5f3d7cfb8148cc80275a0736976726432b174f3)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
13
|
+
* **playwright-test:** wait for Photographer to finish taking screenshots before dismissing actors ([b0c5adb](https://github.com/serenity-js/serenity-js/commit/b0c5adba83fc92624e91c7385b38f0061cf5a6ed)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
14
|
+
* **playwright:** corrected not(isPresent()) for PlaywrightPageElement ([0693b2f](https://github.com/serenity-js/serenity-js/commit/0693b2f2666a8de327c990c72ecf42fc3d7da498)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
15
|
+
* **playwright:** upgraded Playwright to 1.26.0 ([a13ab3c](https://github.com/serenity-js/serenity-js/commit/a13ab3c54b37a5017beadf1db2b2cd2e747d8ab4))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **console-reporter:** improved support for tests executed in parallel ([01264ce](https://github.com/serenity-js/serenity-js/commit/01264ce6110a3199265468f633eee5623fabe008)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
21
|
+
* **core:** serenity/JS stage crew members can now be configured using `string` ([786cdad](https://github.com/serenity-js/serenity-js/commit/786cdadcda8e031e06b8bee9698a87a7af00d90c)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240) [#594](https://github.com/serenity-js/serenity-js/issues/594)
|
|
22
|
+
* **playwright-test:** first draft of the Serenity/JS Playwright Test reporter ([b9e3d89](https://github.com/serenity-js/serenity-js/commit/b9e3d89752c07ef0fd54ad748c31fd7207665c3a)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
23
|
+
* **playwright-test:** improved Playwright Test reports ([6c6b537](https://github.com/serenity-js/serenity-js/commit/6c6b5379dfc324a4fb75d758daa7782109f1c5ab)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
|
24
|
+
* **playwright-test:** support Screenplay Pattern-style scenarios ([c425c54](https://github.com/serenity-js/serenity-js/commit/c425c548034de1b8db60e83671abcb77f9b246e5)), closes [#1240](https://github.com/serenity-js/serenity-js/issues/1240)
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright 2016- Jan Molak, smartcode ltd.
|
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
_** This README is for Serenity/JS version 3.0-RC. Some links might not work yet as we're working on getting the new website and API docs ready. Thanks for your patience and support! **_
|
|
2
|
+
|
|
3
|
+
# Serenity/JS
|
|
4
|
+
|
|
5
|
+
[Serenity/JS](https://serenity-js.org) is a framework designed to make acceptance and regression testing
|
|
6
|
+
of modern full-stack applications faster, more collaborative and easier to scale.
|
|
7
|
+
|
|
8
|
+
Visit [serenity-js.org](https://serenity-js.org/) for the [latest tutorials](https://serenity-js.org/handbook/)
|
|
9
|
+
and [API docs](https://serenity-js.org/modules/), and follow [@SerenityJS](https://twitter.com/SerenityJS) and [@JanMolak](https://twitter.com/JanMolak) on Twitter for project updates.
|
|
10
|
+
|
|
11
|
+
[](https://twitter.com/@SerenityJS)
|
|
12
|
+
[](https://twitter.com/@JanMolak)
|
|
13
|
+
[](https://gitter.im/serenity-js/Lobby)
|
|
14
|
+
|
|
15
|
+
Subscribe to [Serenity/JS YouTube channel](https://www.youtube.com/channel/UC0RdeVPyjtJopVHvlLrXd1Q) to get notified when new demos and video tutorials are available.
|
|
16
|
+
|
|
17
|
+
### Learning Serenity/JS
|
|
18
|
+
|
|
19
|
+
To learn more about Serenity/JS, [follow the tutorial](https://serenity-js.org/handbook/thinking-in-serenity-js/index.html), [review the examples](https://github.com/serenity-js/serenity-js/tree/main/examples), and create your own test suite using the [Serenity/JS template projects](https://github.com/serenity-js).
|
|
20
|
+
|
|
21
|
+
If you have any questions, join us on [Serenity/JS Community Chat](https://gitter.im/serenity-js/Lobby).
|
|
22
|
+
|
|
23
|
+
## Serenity/JS Playwright Test
|
|
24
|
+
|
|
25
|
+
[`@serenity-js/playwright-test`](https://serenity-js.org/api/playwright-test/) module offers a Serenity/JS reporter
|
|
26
|
+
and fixtures that integrate [Playwright Test](https://playwright.dev/docs/intro) with Serenity/JS Screenplay Pattern APIs.
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
To install this module, use an existing [Playwright project](https://playwright.dev/docs/intro) or generate a new one by running:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm init playwright@latest
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Next, run the following command in your Playwright project directory:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install --save-dev @serenity-js/{assertions,console-reporter,core,serenity-bdd,web,playwright,playwright-test}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Serenity/JS Playwright Fixtures
|
|
43
|
+
|
|
44
|
+
To use Serenity/JS Screenplay Pattern APIs and benefit from the in-depth reporting capabilities,
|
|
45
|
+
import Serenity/JS test fixtures instead of the default ones:
|
|
46
|
+
|
|
47
|
+
```diff
|
|
48
|
+
// example.spec.ts
|
|
49
|
+
+ import { test } from '@serenity-js/playwright-test'
|
|
50
|
+
- import { test } from '@playwright/test'
|
|
51
|
+
|
|
52
|
+
test.describe('Serenity Screenplay with Playwright', () => {
|
|
53
|
+
|
|
54
|
+
test.describe('New Todo', () => {
|
|
55
|
+
|
|
56
|
+
test('should allow me to add todo items', async ({ page }) => {
|
|
57
|
+
//...
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you prefer, Serenity/JS also offers the more concise BDD-style `describe/it` syntax:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// example.spec.ts
|
|
67
|
+
import { describe, it, test } from '@serenity-js/playwright-test'
|
|
68
|
+
|
|
69
|
+
test.use({
|
|
70
|
+
headles: true,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('Serenity Screenplay with Playwright', () => {
|
|
74
|
+
|
|
75
|
+
describe('New Todo', () => {
|
|
76
|
+
|
|
77
|
+
it('should allow me to add todo items', async ({ page }) => {
|
|
78
|
+
//...
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Serenity/JS Screenplay Pattern Actors
|
|
85
|
+
|
|
86
|
+
Serenity/JS test fixtures simplify how you instantiate and use Serenity/JS Screenplay Pattern Actors.
|
|
87
|
+
|
|
88
|
+
#### Single-actor scenarios
|
|
89
|
+
|
|
90
|
+
If your tests need only a single actor, you can inject it using the `actor` fixture.
|
|
91
|
+
To configure the name of your default actor, use the `defaultActorName` configuration property:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// example.spec.ts
|
|
95
|
+
|
|
96
|
+
import { describe, it, test } from '@serenity-js/playwright-test' // import fixtures
|
|
97
|
+
import { Navigate, Page } from '@serenity-js/playwright' // import Screenplay Pattern Web APIs
|
|
98
|
+
import { Ensure, equals } from '@serenity-js/assertions' // import Screenplay Pattern assertion APIs
|
|
99
|
+
|
|
100
|
+
test.use({
|
|
101
|
+
headles: true,
|
|
102
|
+
defaultActorName: 'Serena' // change default actor name
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
describe('Serenity Screenplay with Playwright', () => {
|
|
106
|
+
|
|
107
|
+
describe('New Todo', () => {
|
|
108
|
+
|
|
109
|
+
// inject default actor:
|
|
110
|
+
it('should allow me to add todo items', async ({ actor }) => {
|
|
111
|
+
|
|
112
|
+
// define test workflow
|
|
113
|
+
await actor.attemptsTo(
|
|
114
|
+
Navigate.to('https://todo-app.serenity-js.org/'),
|
|
115
|
+
Ensure.that(Page.current().title(), equals('Serenity/JS TodoApp')),
|
|
116
|
+
)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Multi-actor scenarios
|
|
123
|
+
|
|
124
|
+
For multi-actor scenarios where you need each actor to use a separate browser, use the `actorCalled` fixture.
|
|
125
|
+
You can also use this pattern to override the default actor name on a per-scenario basis:
|
|
126
|
+
|
|
127
|
+
```````typescript
|
|
128
|
+
// example.spec.ts
|
|
129
|
+
|
|
130
|
+
import { describe, it, test } from '@serenity-js/playwright-test' // import fixtures
|
|
131
|
+
|
|
132
|
+
describe('Serenity Screenplay with Playwright', () => {
|
|
133
|
+
|
|
134
|
+
describe('Chat app', () => {
|
|
135
|
+
|
|
136
|
+
it('should allow actors to send and receive messages', async ({ actorCalled }) => {
|
|
137
|
+
|
|
138
|
+
// define part of the workflow performed by the first actor:
|
|
139
|
+
await actorCalled('Alice').attemptsTo(
|
|
140
|
+
// navigate to a chat app
|
|
141
|
+
// post a message to Bob
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
// define parts of the workflow performed by the any other actors:
|
|
145
|
+
await actorCalled('Bob').attemptsTo(
|
|
146
|
+
// navigate to a chat app
|
|
147
|
+
// post a reply to Alice
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
// Note that invoking actorCalled(name) multiple times
|
|
151
|
+
// while using the same name and within the scope of a single test
|
|
152
|
+
// returns the same actor, so you don't need to cache them:
|
|
153
|
+
await actorCalled('Alice').attemptsTo(
|
|
154
|
+
// check if the reply from Bob is received
|
|
155
|
+
)
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
```````
|
|
160
|
+
|
|
161
|
+
#### Customising Actors
|
|
162
|
+
|
|
163
|
+
The default [cast](https://serenity-js.org/api/core/class/Cast) of actors is limited to using a single ability
|
|
164
|
+
to [`BrowseTheWebWithPlaywright`](/api/playwright/class/BrowseTheWebWithPlaywright).
|
|
165
|
+
|
|
166
|
+
If you'd like to give your actors additional abilities, like to [`TakeNotes`](https://serenity-js.org/api/core/class/TakeNotes),
|
|
167
|
+
[`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi),
|
|
168
|
+
or [`ManageALocalServer`](https://serenity-js.org/api/local-server/class/ManageALocalServer), you can install the relevant Serenity/JS module
|
|
169
|
+
and configure them as follows:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// example.spec.ts
|
|
173
|
+
|
|
174
|
+
import { Cast, TakeNotes } from '@serenity-js/core'
|
|
175
|
+
import { test } from '@serenity-js/playwright-test'
|
|
176
|
+
import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
177
|
+
import { CallAnApi } from '@serenity-js/rest'
|
|
178
|
+
|
|
179
|
+
test.use({
|
|
180
|
+
actors: async ({ browser, baseURL }, use) => {
|
|
181
|
+
await use(
|
|
182
|
+
Cast.whereEveryoneCan(
|
|
183
|
+
BrowseTheWebWithPlaywright.using(browser),
|
|
184
|
+
TakeNotes.usingAnEmptyNotepad(),
|
|
185
|
+
CallAnApi.at(baseURL),
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For scenarios where different actors need to be configured differently, you can also implement your own `Cast`:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// example.spec.ts
|
|
196
|
+
|
|
197
|
+
import { Cast } from '@serenity-js/core'
|
|
198
|
+
import { BrowseTheWebWithPlaywright, PlaywrightOptions } from '@serenity-js/playwright'
|
|
199
|
+
import { test } from '@serenity-js/playwright-test'
|
|
200
|
+
import { CallAnApi } from '@serenity-js/rest'
|
|
201
|
+
import { Browser } from 'playwright'
|
|
202
|
+
|
|
203
|
+
class Actors implements Cast {
|
|
204
|
+
constructor(
|
|
205
|
+
private readonly browser: Browser,
|
|
206
|
+
private readonly options: PlaywrightOptions,
|
|
207
|
+
) {
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
prepare(actor: Actor) {
|
|
211
|
+
switch (actor.name) {
|
|
212
|
+
case 'James':
|
|
213
|
+
return actor.whoCan(BrowseTheWebWithPlaywright.using(this.browser, this.options))
|
|
214
|
+
default:
|
|
215
|
+
return actor.whoCan(CallAnApi.at(this.options.baseURL))
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
test.use({
|
|
221
|
+
actors: async ({ browser, config }) => {
|
|
222
|
+
await use(new Actors(browser, {
|
|
223
|
+
defaultNavigationWaitUntil: 'domcontentloaded'
|
|
224
|
+
}))
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Serenity Reports
|
|
230
|
+
|
|
231
|
+
To use Serenity/JS reporting capabilities, register the `@serenity-js/playwright-test` reporter in your
|
|
232
|
+
`playwright.config.ts` and define the appropriate reporting services (a.k.a. your "stage crew").
|
|
233
|
+
|
|
234
|
+
For example, to enable Serenity/JS Console Reporter and Serenity BDD reporter, install the relevant modules:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
npm install --save-dev @serenity-js/{console-reporter,serenity-bdd}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Next, configure your Playwright project as follows:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
// playwright.conf.ts
|
|
244
|
+
|
|
245
|
+
import type { PlaywrightTestConfig } from '@playwright/test'
|
|
246
|
+
|
|
247
|
+
const config: PlaywrightTestConfig = {
|
|
248
|
+
reporter: [
|
|
249
|
+
[ '@serenity-js/playwright-test', {
|
|
250
|
+
crew: [
|
|
251
|
+
'@serenity-js/serenity-bdd',
|
|
252
|
+
'@serenity-js/console-reporter',
|
|
253
|
+
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
|
|
254
|
+
// '@serenity-js/core:StreamReporter',
|
|
255
|
+
]
|
|
256
|
+
}],
|
|
257
|
+
|
|
258
|
+
// optional
|
|
259
|
+
[ 'html', { open: 'never' } ], // built-in Playwright HTML reporter
|
|
260
|
+
],
|
|
261
|
+
|
|
262
|
+
// Other configuration omitted for brevity
|
|
263
|
+
// For details, see https://playwright.dev/docs/test-configuration
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export default config
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Note that Serenity/JS reporters work well with the built-in [Playwright reporters](https://playwright.dev/docs/test-reporters).
|
|
270
|
+
|
|
271
|
+
### Reference implementation
|
|
272
|
+
|
|
273
|
+
You can find a reference implementation demonstrating how to integrate Serenity/JS with Playwright Test in the [Serenity/JS
|
|
274
|
+
GitHub repository](https://github.com/serenity-js/serenity-js/tree/main/examples/playwright-test-todomvc).
|
|
275
|
+
|
|
276
|
+
## More coming soon!
|
|
277
|
+
|
|
278
|
+
New features, tutorials, and demos are coming soon, so follow us on Twitter and join the [Serenity/JS Community chat channel](https://gitter.im/serenity-js/Lobby) to stay up to date!
|
|
279
|
+
|
|
280
|
+
[](https://twitter.com/@SerenityJS)
|
|
281
|
+
[](https://twitter.com/@JanMolak)
|
|
282
|
+
[](https://gitter.im/serenity-js/Lobby)
|
|
283
|
+
|
|
284
|
+
If you enjoy using Serenity/JS and would like to keep new features coming, become our [GitHub Sponsor](https://github.com/sponsors/serenity-js)
|
|
285
|
+
and donate as much or as little as you find appropriate.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PlaywrightTestConfig as BasePlaywrightTestConfig } from '@playwright/test';
|
|
2
|
+
import { ClassDescription } from '@serenity-js/core';
|
|
3
|
+
export declare type PlaywrightTestConfig<BaseConfig extends BasePlaywrightTestConfig = BasePlaywrightTestConfig> = Omit<BaseConfig, 'use' | 'reporter'> & {
|
|
4
|
+
use?: BaseConfig['use'] & {
|
|
5
|
+
crew: Array<ClassDescription>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=PlaywrightTestConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaywrightTestConfig.d.ts","sourceRoot":"","sources":["../src/PlaywrightTestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,oBAAY,oBAAoB,CAAC,UAAU,SAAS,wBAAwB,GAAG,wBAAwB,IAAI,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,UAAU,CAAC,GAAG;IAC9I,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG;QAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;KAAE,CAAA;CAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaywrightTestConfig.js","sourceRoot":"","sources":["../src/PlaywrightTestConfig.ts"],"names":[],"mappings":""}
|
package/lib/api.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from '@playwright/test';
|
|
2
|
+
import { Actor, Cast, Duration, Serenity, SerenityConfig, StageCrewMember } from '@serenity-js/core';
|
|
3
|
+
export interface SerenityFixtures extends SerenityConfig {
|
|
4
|
+
actors: Cast;
|
|
5
|
+
crew: StageCrewMember[];
|
|
6
|
+
cueTimeout: Duration;
|
|
7
|
+
serenity: Serenity;
|
|
8
|
+
platform: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
actorCalled: (name: string) => Actor;
|
|
13
|
+
defaultActorName: string;
|
|
14
|
+
actor: Actor;
|
|
15
|
+
}
|
|
16
|
+
export declare type SerenityTestType = TestType<PlaywrightTestArgs & PlaywrightTestOptions & SerenityFixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
|
|
17
|
+
export declare const it: SerenityTestType;
|
|
18
|
+
export declare const test: SerenityTestType;
|
|
19
|
+
export declare const describe: SerenityTestType['describe'];
|
|
20
|
+
export declare const beforeAll: SerenityTestType['beforeAll'];
|
|
21
|
+
export declare const beforeEach: SerenityTestType['beforeEach'];
|
|
22
|
+
export declare const afterEach: SerenityTestType['afterEach'];
|
|
23
|
+
export declare const afterAll: SerenityTestType['afterAll'];
|
|
24
|
+
export declare const expect: SerenityTestType['expect'];
|
|
25
|
+
//# sourceMappingURL=api.d.ts.map
|
package/lib/api.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAA0B,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9J,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAgC,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASnI,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,UAAU,EAAE,QAAQ,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,oBAAY,gBAAgB,GAAG,QAAQ,CAAC,kBAAkB,GAAG,qBAAqB,GAAG,gBAAgB,EAAE,oBAAoB,GAAG,uBAAuB,CAAC,CAAC;AAEvJ,eAAO,MAAM,EAAE,EAAE,gBAyFf,CAAC;AAEH,eAAO,MAAM,IAAI,EAAE,gBAAqB,CAAC;AACzC,eAAO,MAAM,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAe,CAAC;AAClE,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAgB,CAAC;AACrE,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAiB,CAAC;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"}
|
package/lib/api.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.expect = exports.afterAll = exports.afterEach = exports.beforeEach = exports.beforeAll = exports.describe = exports.test = exports.it = void 0;
|
|
27
|
+
const test_1 = require("@playwright/test");
|
|
28
|
+
const core_1 = require("@serenity-js/core");
|
|
29
|
+
const events_1 = require("@serenity-js/core/lib/events");
|
|
30
|
+
const model_1 = require("@serenity-js/core/lib/model");
|
|
31
|
+
const playwright_1 = require("@serenity-js/playwright");
|
|
32
|
+
const os = __importStar(require("os"));
|
|
33
|
+
const reporter_1 = require("./reporter");
|
|
34
|
+
exports.it = test_1.test.extend({
|
|
35
|
+
cueTimeout: core_1.Duration.ofSeconds(5),
|
|
36
|
+
crew: [],
|
|
37
|
+
// eslint-disable-next-line no-empty-pattern
|
|
38
|
+
platform: ({}, use) => {
|
|
39
|
+
const platform = os.platform();
|
|
40
|
+
// https://nodejs.org/api/process.html#process_process_platform
|
|
41
|
+
const name = platform === 'win32'
|
|
42
|
+
? 'Windows'
|
|
43
|
+
: (platform === 'darwin' ? 'macOS' : 'Linux');
|
|
44
|
+
use({ name, version: os.release() });
|
|
45
|
+
},
|
|
46
|
+
serenity: async ({ crew, cueTimeout, platform }, use, info) => {
|
|
47
|
+
const domainEventBuffer = new reporter_1.DomainEventBuffer();
|
|
48
|
+
core_1.serenity.configure({
|
|
49
|
+
cueTimeout: cueTimeout,
|
|
50
|
+
crew: [
|
|
51
|
+
...crew,
|
|
52
|
+
domainEventBuffer,
|
|
53
|
+
new reporter_1.PlaywrightStepReporter(info),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
core_1.serenity.announce(new events_1.SceneTagged(core_1.serenity.currentSceneId(), new model_1.PlatformTag(platform.name, platform.version), core_1.serenity.currentTime()));
|
|
57
|
+
await use(core_1.serenity);
|
|
58
|
+
const serialisedEvents = [];
|
|
59
|
+
for (const event of domainEventBuffer.flush()) {
|
|
60
|
+
serialisedEvents.push({
|
|
61
|
+
type: event.constructor.name,
|
|
62
|
+
value: event.toJSON(),
|
|
63
|
+
});
|
|
64
|
+
if (event instanceof events_1.SceneTagged) {
|
|
65
|
+
exports.test.info().annotations.push({ type: event.tag.type, description: event.tag.name });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
test_1.test.info().attach('serenity-js-events.json', {
|
|
69
|
+
contentType: reporter_1.SERENITY_JS_DOMAIN_EVENTS_ATTACHMENT_CONTENT_TYPE,
|
|
70
|
+
body: Buffer.from(JSON.stringify(serialisedEvents), 'utf8'),
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
actors: async ({ browser }, use) => {
|
|
74
|
+
await use(core_1.Cast.whereEveryoneCan(playwright_1.BrowseTheWebWithPlaywright.using(browser)));
|
|
75
|
+
},
|
|
76
|
+
defaultActorName: 'Serena',
|
|
77
|
+
actor: async ({ actorCalled, defaultActorName }, use) => {
|
|
78
|
+
await use(actorCalled(defaultActorName));
|
|
79
|
+
},
|
|
80
|
+
actorCalled: async ({ serenity, actors, browser, browserName }, use) => {
|
|
81
|
+
serenity.engage(actors);
|
|
82
|
+
const sceneId = serenity.currentSceneId();
|
|
83
|
+
const actorCalled = serenity.theActorCalled.bind(serenity);
|
|
84
|
+
serenity.announce(new events_1.SceneTagged(sceneId, new model_1.BrowserTag(browserName, browser.version()), serenity.currentTime()));
|
|
85
|
+
await use(actorCalled);
|
|
86
|
+
serenity.announce(new events_1.SceneFinishes(sceneId, serenity.currentTime()));
|
|
87
|
+
await core_1.serenity.waitForNextCue();
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
exports.test = exports.it;
|
|
91
|
+
exports.describe = exports.it.describe;
|
|
92
|
+
exports.beforeAll = exports.it.beforeAll;
|
|
93
|
+
exports.beforeEach = exports.it.beforeEach;
|
|
94
|
+
exports.afterEach = exports.it.afterEach;
|
|
95
|
+
exports.afterAll = exports.it.afterAll;
|
|
96
|
+
exports.expect = exports.it.expect;
|
|
97
|
+
//# sourceMappingURL=api.js.map
|