-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarified the example scenarios. Thanks for the feedback, @muhqu
- Loading branch information
Showing
1 changed file
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,78 @@ | ||
import { Ensure, equals } from '@serenity-js/assertions'; | ||
import { actorCalled } from '@serenity-js/core'; | ||
import { By, Navigate, PageElement, Text } from '@serenity-js/web'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import { GitHubStatus } from '../src/github'; | ||
import { Homepage } from '../src/serenity'; | ||
|
||
/** | ||
* Serenity/JS Screenplay Pattern test scenarios use one or more actors to represent people and external systems | ||
* interacting with the system under test. | ||
* | ||
* To design a test scenario, give each actor a series of tasks and interactions to perform | ||
* and instruct them to answer questions about the state of the system under test | ||
* to ensure that the answers meet the expected results. | ||
* | ||
* This example test file demonstrates several ways of writing test scenarios using the Screenplay Pattern. | ||
* | ||
* Learn more: | ||
* - Serenity/JS Screenplay Pattern - https://serenity-js.org/handbook/design/screenplay-pattern/ | ||
* - Web Testing with Serenity/JS - https://serenity-js.org/handbook/web-testing/ | ||
* - API Testing with Serenity/JS - https://serenity-js.org/handbook/api-testing/ | ||
* - Serenity/JS web module - https://serenity-js.org/api/web/ | ||
* - Serenity/JS REST module - https://serenity-js.org/api/rest/ | ||
* - Serenity/JS assertions module - https://serenity-js.org/api/assertions/ | ||
*/ | ||
describe('Serenity/JS Website', () => { | ||
|
||
it(`tells people what the framework can help them do`, async () => { | ||
|
||
/** | ||
* This is the most basic example of a Serenity/JS Screenplay Pattern test scenario. | ||
* | ||
* This scenario uses a single actor configured to perform a series of web-based interactions, | ||
* and uses only the low-level abstractions provided by the Serenity/JS web module. | ||
*/ | ||
it('offers a web testing tutorial', async () => { | ||
await actorCalled('Alice').attemptsTo( | ||
Navigate.to('https://serenity-js.org'), | ||
Ensure.that( | ||
Text.of(PageElement.located(By.id('cta-start-automating'))), | ||
equals('Start automating 🚀') | ||
), | ||
) | ||
}); | ||
|
||
/** | ||
* This is a more advanced example of a Serenity/JS Screenplay Pattern test scenario. | ||
* | ||
* This scenario uses two actors: | ||
* - Apisitt, responsible for interacting with an API to check if the system is up and running before performing any UI checks | ||
* - Wendy, responsible for interacting with the website to perform the actual acceptance test | ||
* | ||
* In this scenario, rather than list all the interactions in the test itself, we use: | ||
* - API Actions Class Pattern to group tasks concerning interacting with the GitHubStatus API | ||
* - Page Objects Pattern to group tasks and questions concerning interacting with the Serenity/JS Homepage | ||
* | ||
* Note that apart from strongly encouraging the Screenplay Pattern, | ||
* Serenity/JS doesn't require you to organise your code in any particular way. | ||
* This gives you the freedom to choose patterns and abstractions that work best for you, your team, | ||
* and reflect the domain of your system under test. | ||
*/ | ||
it(`tells people what the framework can help them do`, async () => { | ||
|
||
// You can use API interactions to ensure services are up and running before performing any UI checks, | ||
// or to manage test data | ||
// You can use API interactions to manage test data, or to ensure services are up and running before performing any UI checks. | ||
// Since Serenity/JS website is deployed to GitHub Pages, before interacting with the website we ensure that GitHub is up and running. | ||
await actorCalled('Apisitt').attemptsTo( | ||
GitHubStatus.ensureAllSystemsOperational(), | ||
); | ||
|
||
// Once we know the system is up and running, Wendy can proceed with the web-based scenario. | ||
await actorCalled('Wendy').attemptsTo( | ||
Homepage.open(), | ||
|
||
Ensure.that( | ||
Homepage.heroBannerHeadingText(), | ||
equals('Enable collaborative test automation at any scale!') | ||
), | ||
) | ||
); | ||
}); | ||
}); |