Socket
Socket
Sign inDemoInstall

feynman

Package Overview
Dependencies
21
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    feynman

A screenplay pattern library for javascript


Version published
Weekly downloads
2
Maintainers
4
Install size
10.6 MB
Created
Weekly downloads
 

Readme

Source

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 } = require('feynman')

const dave = await actor('dave')
await dave.attemptsTo(PostMessageInSlack)

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 CFCJMB2K0
const PostMessageInSlack = ({ slack }) => slack.chat.postMessage({ channel, text: "Hello world!" })

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 } = require('feynman')
  const { WebClient } = require('@slack/client')
  const token = process.env.SLACK_TOKEN
  const slack = new WebClient(token)

  abilities({ slack })

  const channel = 'YOURCHANNEL' // should look like CFCJMB2K0
  const PostMessageInSlack = ({ slack }) => slack.chat.postMessage({ channel, text: "Hello world!" })

  const dave = await actor('dave')
  await dave.attemptsTo(PostMessageInSlack)
})()

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

FAQs

Last updated on 12 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc