Your first web scenario
In this guide, you'll learn the basics of web testing with Serenity/JS; I'll show you how to run and debug existing tests and write new test scenarios. While we'll focus on helping you get the basics right, I'll point you to the more advanced techniques and patterns when needed.
My goal with all the Serenity/JS guides in this handbook, including this one, is that they're easy to follow whether you're a test automation expert or just starting on your journey. If you found anything here that could have been clearer, please let me know in the comments or submit a correction.
To keep things simple, we'll use a Gitpod.io workspace to work with Serenity/JS in your web browser, so there's no need to install anything on your computer. If you prefer to set up Serenity/JS locally instead, follow the installation instructions in Serenity/JS + Playwright Test project template.
In this tutorial, you'll learn that:
- Serenity/JS works well with popular development environments, including the free Visual Studio Code,
- Serenity/JS tests are just high-quality code, so all your regular programming tools will work as expected,
- Serenity/JS test scenarios are actor-centric and follow the Screenplay Pattern to help you capture business domain vocabulary and business workflows,
- Serenity/JS uses an activity-based composition model, optimised for readability and code reuse,
- Serenity/JS assertions and synchronisation statements are portable across interfaces and integration tools,
- Serenity/JS has first-class support for TypeScript and the asynchronous nature of the JavaScript runtime.
If you get lost or stumble upon a problem you're not quite sure how to solve - ask on the Serenity/JS Community Chat.
Launching your workspace
All Serenity/JS project templates, such as the one we'll use in this chapter, support Gitpod.io workspaces and are configured to make it easy for you to use them in a Visual Studio Code-based development environment. Of course, since Serenity/JS tests are standards-based Node.js code, they'll work just as well in any other modern IDE.
In this tutorial, we'll use Serenity/JS + Playwright Test template, which integrates Serenity/JS with Playwright web testing library and its dedicated Playwright Test test runner. The test suite we'll work on interacts with a simple to-do list app that you can experiment with at todo-app.serenity-js.org.
To launch your workspace, make sure you have a GitHub account, which will make it easier for you to use all the other Serenity/JS resources, too.
Next, launch your Gitpod.io web IDE using the "Open in Gitpod" button below and sign in to your Gitpod.io workspace using your GitHub account.
Serenity/JS integrates with several popular test runners, such as Cucumber, Mocha, Jasmine and Playwright Test, as well as various web integration tools, such as Selenium, Playwright and WebdriverIO. Once you know your way around your first Serenity/JS project template, picking the one right for your team and your project will become a breeze.
Running tests in Visual Studio Code
Serenity/JS + Playwright Test template
you've just opened in your Gitpod workspace includes several example test scenarios
located under the spec
directory.
You can view them using your Visual Studio Code Project Explorer sidebar, which should show a directory structure similar to this:
There are two ways to run Playwright tests in Visual Studio Code, and you can do it either by:
- using the play/check mark icon next to the name of the test in a
.spec.ts
file, - using the play icon in the Visual Studio Code Test Explorer panel, which shows all the test scenarios Visual Studio Code has detected in your project, as per the screenshot below:

Once you've inspected the spec/recording_items.spec.ts
,
you will notice that we're using two functions provided by the @serenity-js/playwright-test
module that help to organise a test suite:
Those describe
and it
functions are wrappers around
Playwright Test test.describe
and test
functions, respectively.
In addition to the functionality offered by Playwright test
function, Serenity/JS it
wrapper offers Serenity/JS-specific test fixtures,
such as actor
,
actorCalled
,
or crew
.
I'll tell you about them in a moment, but first, let's run the scenarios.
If Visual Studio Code didn't detect any test scenarios in your project, or if it doesn't display the play/check mark icon next to the name of the test, use the "Refresh Tests" icon in the Test Explorer to reload test configuration.

Exercises
To get familiar with running Serenity/JS test scenarios in Visual Studio Code, conduct the following experiments:
- Open
spec/recording_items.spec.ts
and run test scenarios such asit('should clear text input field when an item is added')
individually using the play/check mark icon next to theit
block. Make sure they're passing. - Run a group of test scenarios by clicking on the play/check mark icon next to the
describe
block, such asdescribe('Todo List App')
. Make sure they're passing. - Run individual test scenarios using Visual Studio Code Test Explorer panel.
- Navigate from a test scenario in a Visual Studio Code Test Explorer panel to its location in the codebase using the "Go to test" icon next to the name of the test.
Writing Serenity/JS test scenarios
Now that you know how to run Serenity/JS test scenarios in VS Code, let's talk about what's involved in writing some new ones.
First, add the below code snippet to your existing test suite in spec/recording_items.spec.ts
by placing it inside the describe('Todo List App')
block.
describe('Todo List App', () => {
it('should allow me to add a todo item', async ({ actor }) => {
await actor.attemptsTo(
startWithAnEmptyList(),
recordItem('Buy some milk'),
Ensure.that(itemNames(), equals([
'Buy some milk',
])),
)
})
// other test scenarios
})
Well done, you've just created your first Serenity/JS test scenario!
Make sure that you can run this new scenario and that it's passing, and we'll analyse its structure line by line in just a moment.

As you can see in the listing above, well-written Serenity/JS test scenarios are concise, easy to read, and easy to understand even to audiences who might not necessarily have background in technology. That's because Serenity/JS is designed to help you express your scenarios in the domain language of your company and your business and avoid incidental detail and low-level implementation noise that could cloud the picture.