Serenity/JS
Serenity/JS is an innovative open-source framework designed to make acceptance and regression testing
of complex software systems faster, more collaborative and easier to scale.
⭐️ Get started with Serenity/JS!
👋 Join the Serenity/JS Community!
Serenity/JS WebdriverIO
@serenity-js/webdriverio
module is a Screenplay Pattern-style adapter
for WebdriverIO that will help you with testing Web and mobile apps.
Installation
To install this module, run the following command in your WebdriverIO project directory:
npm install --save-dev @serenity-js/{assertions,console-reporter,core,serenity-bdd,web,webdriverio}
Next, install a Serenity/JS test runner adapter appropriate for your preferred test runner.
Usage with Cucumber.js
To use Serenity/JS WebdriverIO with Cucumber.js, install the following adapter:
npm install --save-dev @serenity-js/cucumber
Please note that Serenity/JS WebdriverIO / Cucumber integration supports both Serenity/JS reporting services and native Cucumber.js reporters.
Usage with Jasmine
To use Serenity/JS WebdriverIO with Jasmine, install the following adapter:
npm install --save-dev @serenity-js/jasmine
Usage with Mocha
To use Serenity/JS WebdriverIO with Mocha, install the following adapter:
npm install --save-dev @serenity-js/mocha
Configuring WebdriverIO
To integrate Serenity/JS with WebdriverIO,
configure your wdio.conf.ts
to specify framework: '@serenity-js/webdriverio'
.
You can configure Serenity/JS in the same file.
import { Actors } from './serenity/Actors.ts'
export const config: WebdriverIOConfig = {
framework: '@serenity-js/webdriverio',
serenity: {
runner: 'cucumber',
actors: new Actors(`https://api.example.org`),
crew: [
'@serenity-js/console-reporter',
'@serenity-js/serenity-bdd',
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
[ '@serenity-js/web:Photographer', {
strategy: 'TakePhotosOfFailures',
} ],
]
},
cucumberOpts: {
},
jasmineOpts: {
},
mochaOpts: {
},
specs: [
'./features/**/*.feature',
],
};
Learn more about:
Using custom Serenity/JS Actors
By default, Serenity/JS uses a default cast of actors where every actor can:
If you're planning to implement scenarios where actors have
additional abilities, you can replace this default setup
with a custom Cast
, like this one:
import { Actor, Cast, TakeNotes } from '@serenity-js/core';
import { CallAnApi } from '@serenity-js/rest';
import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
import type { Browser } from 'webdriverio';
export class Actors implements Cast {
constructor(private readonly apiUrl: string) {
}
prepare(actor: Actor): Actor {
switch (actor.name) {
case 'Apisitt':
return actor.whoCan(
CallAnApi.at(this.apiUrl)
);
default:
return actor.whoCan(
BrowseTheWebWithWebdriverIO.using(browser),
TakeNotes.usingAnEmptyNotepad(),
);
}
}
}
Using Serenity/JS with WebdriverIO and Mocha
import { actorCalled } from '@serenity-js/core';
import { Ensure, equals } from '@serenity-js/assertions';
import { By, Navigate, PageElement, Text } from '@serenity-js/web';
import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
class SerenityJSWebsite {
static header = () =>
PageElement.located(By.css('h1'))
.describedAs('header');
}
describe('Serenity/JS', () => {
it('works with WebdriverIO and Mocha', async () => {
await actorCalled('Wendy')
.attemptsTo(
Navigate.to('https://serenity-js.org'),
Ensure.that(
Text.of(SerenityJSWebsite.header()),
equals('Enable collaborative test automation at any scale!')
),
)
});
});
To learn more, check out the example projects.
Template Repositories
The easiest way for you to start writing web-based acceptance tests using Serenity/JS, WebdriverIO and either Mocha, Cucumber or Jasmine is by using one of the below template repositories:
📣 Stay up to date
New features, tutorials, and demos are coming soon!
Follow Serenity/JS on LinkedIn,
subscribe to Serenity/JS channel on YouTube and join the Serenity/JS Community Chat to stay up to date!
Please also make sure to star ⭐️ Serenity/JS on GitHub to help others discover the framework!
💛 Support Serenity/JS
If you appreciate all the effort that goes into making sophisticated tools easy to work with, please support our work and become a Serenity/JS GitHub Sponsor today!