Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qavajs/memory
https://github.com/qavajs/memory
qa test-automation testing
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/qavajs/memory
- Owner: qavajs
- License: mit
- Created: 2022-06-18T08:45:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T16:37:51.000Z (about 2 months ago)
- Last Synced: 2024-10-28T17:43:29.253Z (about 2 months ago)
- Topics: qa, test-automation, testing
- Language: TypeScript
- Size: 243 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/@qavajs%2Fmemory.svg)](https://badge.fury.io/js/@qavajs%2Fmemory)
## @qavajs/memory
This library provides single storage of variables for @qavajs framework
`npm install @qavajs/memory`
## Usage
Lib resolves provided value from storage
```javascript
const memory = require('@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);
});
``````gherkin
When save variable as 'variable'
Then value of '$variable' should be equal to '42'
```## Using constants and computed
Lib provides capability to set constant values and computed (values that calculated in the moment of call)
```javascript
module.exports = {
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```javascript
const memory = require('@qavajs/memory');
const memoryMap = require('./memoryMap.js')
Before(async function() {
memory.register(memoryMap);
});
```## Escape $
_$_ can be escaped with double backslash```Gherkin
When I expect text of 'Currency Label' to equal '\\$42'
```## Parallel
In case you need to assign uniq value for each Cucumber thread and qavajs shard you can use parallel function.
It will assign value based on CUCUMBER_WORKER_ID and SHARD env variables.```javascript
const { parallel } = require('@qavajs/memory/utils');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 });
}module.exports = Memory;
```