Package Exports
- @qavajs/memory
- @qavajs/memory/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@qavajs/memory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@qavajs/memory
Unified test data storage for the @qavajs framework
npm install @qavajs/memoryUsage
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 });
}