Feynman
A library for helping you organise your JavaScript test automation code, inspired by the screenplay pattern.
What's lovely about screenplay, as opposed to other patterns for organising automation code like page objects, is that you're building abstractions around behaviour, rather than solution implementation. We think you're going to like it.
Copared to other screenplay implementations we've seen, what's unique about Feynman is that you can define multiple perspectives that allow you to run the same tasks against your application in different ways.
More on that later.
We're going to assume you know little or nothing about the screenplay pattern and explain this from the ground up. Let's start with an example.
A simple example
const actor = const dave = await await dave
What's going on here?
First, we call the actor
method to get hold of an Actor who we've given the label "dave". It doesn't matter what we
call our actor in this example, but you'll see why it's useful later on.
Next, we ask Dave to attempt an Action, PostMessageInSlack
.
In order to make this code work, we'll need to define that action, as well as giving dave
an Ability that lets our action post messages in Slack.
First we create the action:
const channel = 'YOURCHANNEL' // should look like CFCJMB2K0const PostMessageInSlack = slackchat
So our PostMessageInSlack
action is defined as a function that takes a slack
named parameter, representing the Slack web client API, and calls the API to post a message.
How do we give dave
this ability?
async { const actor abilities = const WebClient = const token = processenvSLACK_TOKEN const slack = token const channel = 'YOURCHANNEL' // should look like CFCJMB2K0 const PostMessageInSlack = slackchat const dave = await await dave}
That's the fundamentals of using Feynman. Read on to learn more about:
- Composing actions
- Creating actions that take parameters
- Giving actors memory
- Using perspectives to run your tests at different levels of the stack
- Using feynman with different test frameworks