Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@qavajs/memory

qavajs12kMIT1.10.3TypeScript support: included

memory package for @qavajs framework

test, automation, testing, qa, quality-assurance, test-framework, test-runner, test-automation, e2e, end-to-end, ui-testing, api-testing, integration-testing, acceptance-testing, functional-testing, browser-testing, mobile-testing, cross-browser, bdd, gherkin, assertions, continuous-delivery, automation-framework

readme

npm version

@qavajs/memory

Unified test data storage for the @qavajs framework

npm install @qavajs/memory

Usage

The module resolves the provided value from storage

import memory from '@qavajs/memory';

When(/^save variable as '(.+)'$/, async function (key) {
    memory.setValue(key, 42);
});

Then(/^value '(.+)' should be equal to '(.+)'$/, async function (variable1, variable2) {
    const val = memory.getValue(variable1);
    expect(val).to.equal(variable2);
});
When save variable as 'variable'
Then value of '$variable' should be equal to '42'

Using constants and computed

The module provides the capability to set constant values and computed (values that are calculated at the moment of call)

export default {
    constant: 42,
    now: function() {
        return Date.now()
    }
};

Register constants and computed

Before using memory, it needs to be registered. The best place to do it is Before hook

import memory from '@qavajs/memory';
import memoryMap from './memoryMap.js';

Before(async function() {
    memory.register(memoryMap);
});

Escape $

$ can be escaped with a double backslash

When I expect text of 'Currency Label' to equal '\\$42'

Parallel

In case you need to assign a unique value for each Cucumber thread and qavajs shard, you can use a parallel function. It will assign value based on CUCUMBER_WORKER_ID and SHARD env variables.

import { parallel } from '@qavajs/memory/utils';

export default class Memory {
    user = parallel([
        { username: 'user1', password: 'password' },
        { username: 'user2', password: 'password' }
    ]);

    // shard mode 
    shardUser = parallel([
        { username: 'user1', password: 'password' },
        { username: 'user2', password: 'password' },
        { username: 'user3', password: 'password' },
        { username: 'user4', password: 'password' }
    ], { shard: true });
}

changelog

Change Log

All notable changes to the "@qavajs/memory" will be documented in this file.

Check Keep a Changelog for recommendations on how to structure this file.

[1.10.3]

  • :beetle: fixed parallel util function to allow undefined values

[1.10.2]

  • :beetle: fixed issue with calling functions in templates

[1.10.1]

  • :beetle: fixed issue with parsing json

[1.10.0]

  • :rocket: added export of Memory type
  • :beetle: fixed issue with nested curly braces

[1.9.0]

  • :rocket: added logging on setValue

[1.8.0]

  • :rocket: added support of top-level getters Breaking Change: all memory values are now stored in storage property

[1.7.1]

  • :rocket: improved error handling to produce more clear errors

[1.7.0]

  • :rocket: updated parallel function to support qavajs shards

[1.6.2]

  • :beetle: disabled logging of non-memory values

[1.6.1]

  • :beetle: fixed issue with unexpected object conversion

[1.6.0]

  • :rocket: added capability to provide logger

[1.5.1]

  • :beetle: fixed issue with non string inputs

[1.5.0]

Breaking Change: Memory no more throwing error if value does not exist. Instead, undefined is returned.

  • :rocket: refactored and simplified whole library
  • :rocket: added $js computed to evaluate expression
    const result = memory.getValue('$js($val + 1)'); // evaluates js expression
  • :rocket: all JS types are now supported in computed

[1.4.2]

  • :beetle: fixed issue with dots in computed params

[1.4.1]

  • :beetle: fixed issue with square brackets in computed params

[1.4.0]

  • :rocket: added parallel util function

[1.3.0]

  • :rocket: implemented chaining of computed results
  • :beetle: fixed empty string as computed param

[1.2.1]

  • :beetle: fixed context for methods calling

[1.2.0]

  • :rocket: implemented capability to escape $

[1.1.1]

  • :beetle: fixed issue that prevent storing functions in memory
  • :beetle: fixed issue with quotes and double quotes