{"id":19845353,"url":"https://github.com/qavajs/memory","last_synced_at":"2025-05-01T21:30:29.352Z","repository":{"id":37392543,"uuid":"504790570","full_name":"qavajs/memory","owner":"qavajs","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-28T16:37:51.000Z","size":249,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-28T17:43:29.253Z","etag":null,"topics":["qa","test-automation","testing"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qavajs.png","metadata":{"files":{"readme":"README.MD","changelog":"CHANGELOG.MD","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-18T08:45:37.000Z","updated_at":"2024-10-28T16:37:27.000Z","dependencies_parsed_at":"2024-01-14T16:03:54.038Z","dependency_job_id":"8bb9808a-8716-4e1b-9730-0106c686a197","html_url":"https://github.com/qavajs/memory","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fmemory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fmemory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fmemory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qavajs%2Fmemory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qavajs","download_url":"https://codeload.github.com/qavajs/memory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224278484,"owners_count":17285080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["qa","test-automation","testing"],"created_at":"2024-11-12T13:07:23.252Z","updated_at":"2024-11-12T13:07:24.333Z","avatar_url":"https://github.com/qavajs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/@qavajs%2Fmemory.svg)](https://badge.fury.io/js/@qavajs%2Fmemory)\n\n## @qavajs/memory\n\nThis library provides single storage of variables for @qavajs framework\n\n`npm install @qavajs/memory`\n## Usage\n       \nLib resolves provided value from storage\n```javascript\nconst memory = require('@qavajs/memory');\n\nWhen(/^save variable as '(.+)'$/, async function (key) {\n    memory.setValue(key, 42);\n});\n\nThen(/^value '(.+)' should be equal to '(.+)'$/, async function (variable1, variable2) {\n    const val = memory.getValue(variable1);\n    expect(val).to.equal(variable2);\n});\n```\n\n```gherkin\nWhen save variable as 'variable'\nThen value of '$variable' should be equal to '42'\n```\n\n## Using constants and computed\n\nLib provides capability to set constant values and computed (values that calculated in the moment of call)\n```javascript\nmodule.exports = {\n    constant: 42,\n    now: function() {\n        return Date.now()\n    }\n};\n```\n## Register constants and computed\nBefore using memory it needs to be registered. The best place to do it is Before hook\n\n```javascript\nconst memory = require('@qavajs/memory');\nconst memoryMap = require('./memoryMap.js')\nBefore(async function() {\n    memory.register(memoryMap);\n});\n```\n\n## Escape $\n_$_ can be escaped with double backslash\n\n```Gherkin\nWhen I expect text of 'Currency Label' to equal '\\\\$42'\n```\n\n## Parallel\nIn case you need to assign uniq value for each Cucumber thread and qavajs shard you can use parallel function.\nIt will assign value based on CUCUMBER_WORKER_ID and SHARD env variables.\n\n```javascript\nconst { parallel } = require('@qavajs/memory/utils');\n\nclass Memory {\n    user = parallel([\n        { username: 'user1', password: 'password' },\n        { username: 'user2', password: 'password' }\n    ]);\n\n    // shard mode \n    shardUser = parallel([\n        { username: 'user1', password: 'password' },\n        { username: 'user2', password: 'password' },\n        { username: 'user3', password: 'password' },\n        { username: 'user4', password: 'password' }\n    ], { shard: true });\n}\n\nmodule.exports = Memory;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqavajs%2Fmemory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqavajs%2Fmemory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqavajs%2Fmemory/lists"}