Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@cucumber-e2e/memory

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber-e2e/memory

Memory model for cucumber frameworks

latest
npmnpm
Version
0.3.0
Version published
Weekly downloads
24
200%
Maintainers
1
Weekly downloads
 
Created
Source

Memory

Memory is the module that allows to easily store and share data between steps. To start using memory just import corresponing class into your tests.

To get element from storage call getValue() method with argument. If you pass simple string that getValue will return it as is.

const { Memory } = require("@cucumber-e2e/memory");
Memory.setValue("YourKey", "Your Value");
Memory.getValue("$YourKey"); //"Your Value"

You can also parse string and replace {memoryKey} patterns with memory values via parseString() method.

const { Memory } = require("@cucumber-e2e/memory");
Memory.setValue("YourKey", "Your Value");
Memory.getValue("String with {$YourKey}"); //"String with Your Value"

Moreover memory module implements several classes to define and store static constant and dynamical values

Define computed value

const { Memory } = require("@cucumber-e2e/memory");
const { ComputedMap } = require("@cucumber-e2e/memory");

class YourComputedMap extends ComputedMap {
    constructor() {
        super();
        this.defineComputed(/^FUNCTION$/, () => {
            return "value"
        });
    }
}
Memory.setComputedInstance(new YourComputedMap()); //attach ComputedMap to Memory
Memory.getValue("#FUNCTION"); //"value"

Define constant

const { Memory } = require("@cucumber-e2e/memory");
const { ConstantMap } = require("@cucumber-e2e/memory");

class YourConstantMap extends ConstantMap {
    constructor() {
        super();
        this.defineConstant("constantKey", "value");
        this.defineFileConstant("fileConstantKey", "./test/file.txt");
    }
}
Memory.setConstantsInstance(new YourConstantMap()); //attach ConstantMap to Memory
Memory.getValue("!constantKey"); //"value"
Memory.getValue("!!fileConstantKey"); // data from "./test/file.txt" file

Keywords

cucumber

FAQs

Package last updated on 18 Feb 2020

Did you know?

Socket

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