{"_id":"@superfaceai/testing","_rev":"31-70c40834e2c22e4d508adee45981c554","name":"@superfaceai/testing","dist-tags":{"latest":"5.0.0","next":"4.0.0-rc.0","beta":"4.0.0-beta.0"},"versions":{"1.0.0":{"name":"@superfaceai/testing","version":"1.0.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.0.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","mockttp":"^2.2.2","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.0.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@1.0.0","dist":{"shasum":"29534282bd70da617470cf325b7b97539fed1261","integrity":"sha512-NVq4uGoXoINTPCw8+b90havUzMnEpxofq/TnhM1/v33lXwa3xwt2W/5z2LTKumLDNQT/qohbZ4OyOwJY0FGR3g==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-1.0.0.tgz","fileCount":37,"unpackedSize":134875,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGyDPqlx5Ll4xFK20Lvmk+OC1rcYnTMklX1nOgTIFNf3AiEAjubyMk2hni7YjzJijBOSwSLRNOc+EqZfHCgiZmX7AvI="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_1.0.0_1636119812234_0.3939078270748384"},"_hasShrinkwrap":false},"1.0.1-rc.0":{"name":"@superfaceai/testing","version":"1.0.1-rc.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.0.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.0.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nYou can enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@1.0.1-rc.0","dist":{"shasum":"be89d2e21a1c2903a42f2888d63af7650118aedc","integrity":"sha512-8j4h5VMb9fKtUkBR3k6EAUaJ9sLbLPldg3qHawTNJ70NfdH3vFO2Btdn/aejuoMw/v56vDugIrUUZ9XmosJgmQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-1.0.1-rc.0.tgz","fileCount":37,"unpackedSize":149278,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhm5+fCRA9TVsSAnZWagAA/hsP/i6aWvRyPQfWL//TMZQd\nBdmzSOd7eRUu0ghufOrUBiC5hEkmtUA+VcEeS/xY+fYspxxktYE2ojiOuF+x\nvEFJKxcR1p4SzcveglT9HumlwBSeHAgnmXU12jGPBlgE/9dslRpC56VYkShm\nn2N9Pek6xujOOjGVeL5iinguu6VX0JJ7HqgUX5Lc2j9qRD9Iz0JtS9WQUExq\nFWwwgDsMxnVGVcCyq02f51ZToE4zCWTPRU3ml7zCUa+EC7dweu26bhOvuNPI\nabstIxWc51Wc7GjJQqD3SU4fYlax6OMKjk2UNkBz2ULQQg5qOqnKDQdjShLD\nHzyqrNriNZwzlbQmjAM52lP6rh7FhMfKgyq5PpavxyxqPc5oCuXAUIV8Fnho\nLyF9CeU/j1Ew46oMyxLDYJr/fYXTpntqoI6YJKzTK2qNNi/b2kdnP63uOsiz\nPTn5a/qN9V8zcvRsxeF/ee89dk4MqeFcuPB8nHETgG1OKvKz1/cxdVKpdL7Q\nYQDhRUOBactUH5htgXXhJ5MAd5IlAprVZEDqXAuxq2DRW5Mmw+7YStMqp1qk\nSRuDJetxKONfC0X+x1OrYPt1rtfjZY4riYrMZ4sacMp2d62G9crkSrC/FHMJ\nc6HeXOpwZnQBbk9tI1SluNJ6vBffejYzQgrz9ux6qo1PPGm44INUyZEjM/0w\n2Gvr\r\n=6mqr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCH1FmdYqsM/YromVALoIL5H8jTkuzeuKNCEBScMT9zFQIhAMuzCZbj/AxBo726sszbJpU7ChuWJpB0BlMJpL1ZDusc"}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_1.0.1-rc.0_1637588894747_0.9771630500544795"},"_hasShrinkwrap":false},"2.0.0-rc.0":{"name":"@superfaceai/testing","version":"2.0.0-rc.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.0.1","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.0.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.0-rc.0","dist":{"shasum":"496b8cfac70005455a9b7c8dee24e797cc88ca40","integrity":"sha512-Ua5sjxEBJmp4vfHlJcthjvMymKiJ7VoIEXK9g3NI3Pt/9LwNAQaKRgjDFhuyBdi/Q6+cSO5tRYjvf4yH5gyNYg==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.0-rc.0.tgz","fileCount":40,"unpackedSize":170069,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhywOBCRA9TVsSAnZWagAAR24P/iJ+SbrTeBiY7BI7AovY\nnqYvLkcyfnV0zoQw8fKY95G3KWm1joEGRyXF1JpngS8X5G0SGXz0iT4aadud\n2PnETWfz2jceBzekIlHr5YM+8C/Lq4TjnBsIFKxPD4RHQfDbSdChUNoDwKT+\neakrwr1fjDMb2Cr/6lHrvuto49Kg3c1En6XjQSMzTG6N4XFz7mjFa8UAViMZ\nEN1xHxwiKh5zORgwBvK82179yox5eTylaz7T56yT+TwVHeAMzrJMm2QSVb+a\nQxo30wzry6Rkf+pnwxXTLdBCg9WaZGihsnvsqJxxa+zkDBDRMnL7a9j0pHIR\nyvXsiZfZq54BqBVF5kEYP4GLQU2qcllSJcBfhjdjkrfG6gGXSsW5v8ag/lrK\nUrynsLYTpySoWqBZAV2BEzCA6vwfq2BJIKVlZRy+FSlvabUqKfpmXGJRFmNm\nPQZOFTHK9VbhCjfSNEvHiWzGKLibsIt/yUUEM6RIS/5zNZej6iQ/PANxdj86\np+Tn4WG80muSepJiyNag+K5bpbRLtXXDZc7rgrw3NGKfaiik/hn1lgIkx9YG\n1lbbiZADF18oKRZf48t0lZA4XweXCeIK7eIemrJVdWVIYpCpJwPKkappa9yp\n5nAcDAzLuOxyr3tRji+OXG/poGRk6TbFzAIqXXc0ZJ+dllh+dQSERq/PsPVy\n8cC8\r\n=ctVZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDn/mMzH+VqKcgTR6/dTjqQdDELmlKUtqNQFF24Lqp9dgIgYZxmfw9LU40bxePrnJ/JVTgnPcRanjZ1GWZUvy6eStw="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.0-rc.0_1640694657768_0.2814285926062472"},"_hasShrinkwrap":false},"2.0.0":{"name":"@superfaceai/testing","version":"2.0.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.0.1","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.0.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.0","dist":{"shasum":"32eca268125d8653383702d6081f1a39f987ee1f","integrity":"sha512-9SyWpI8wMfiIEZSfxQ1bpAQgbvt5w41bV1uiBJLg2MMBxykOofW2EBjSG6neYFKgPBT7juP0cJaF0zF+D1u8SQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.0.tgz","fileCount":40,"unpackedSize":170161,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5T2uCRA9TVsSAnZWagAADbQP/2J/U+1ae9DsOmG/VopQ\nWYh6FTbH8YYaexJpYXGhNh14/RLpkIrHWwG97JOOCTj8sIHJw6MueblavSVD\n6DPFFSy5QGYrebrhtbq2tIMchhyqD8Hcp1w9cxgpbBIKqinRS3ljjNYh9x1Q\nOmAf8nSosmVSRnh7MQLh/ApRp5CKkSyH1Y4X/Smg1395vNNo9xsqNDbLxKAj\ng5VcNKvKpzGDV/QUIZorjTBE6iIz46jFbBiwHnvGWOXv+dcnKh9x0taJEnuW\nk4tQz2d3wOqEqCIOycCOVv93fLKLjJyQtEPUTz5eNRSnLcXWDybmipj2wFYV\nwdpYlYZgs53XnPvKhFpXhbm55nTXcuo4hVs85mMyRioW5IZ36AAvucwfbhC2\nlFd8zfmvnHpAlxiG8B8MhN+/x/q2HNDm9pBT65BlIbCGDbw16dNDqKcNanCR\nQlT2c9u4uLf9t7V/ONII6Vh9z2vEQLlql2pSlXB84cIWkmf2WNcateMI1Jn/\nRWoDuOwwYjemslD2M1cMJTfAEE+eozALm3v0GkH1hxPhC99JOBNHbB81WrqH\nW6G8cAi00Wcgif68Ic3jnHhFFXX8Zj+iDCZgwvCKX8tsrIwcawstoEW/P7OY\n4cr52Rbv8RlKHQv4M7ko7gz2Ws1DTJzAtbfpBmzC7O3tAw5yU4c7h8zi3E2c\nPnUx\r\n=ruue\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCaH/xeNU+GbBob9MVfEej12XkVqjmOzYWJgWgi7OMPIQIgN0wlVCukrG8S6HE5CsRgJQF1ZUICyC9DX/y/bLR2Xf4="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.0_1642413486068_0.45916101708813106"},"_hasShrinkwrap":false},"2.0.1-beta.0":{"name":"@superfaceai/testing","version":"2.0.1-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"1.3.0-rc.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.1-beta.0","dist":{"shasum":"34add9b408ca0c494c9954b9075e0a7ba3ccb252","integrity":"sha512-Xkx5azoYIFHYic4mxBFyRu+50c8zoUVCzgPulT+qu+ML8cqXj1Nyus1w5fWJplCh/3t0JFHpJ2t5ZqQ6eEPtoA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.1-beta.0.tgz","fileCount":40,"unpackedSize":171721,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiCkHVCRA9TVsSAnZWagAACzkP/09DYuFcerNWEPcRU48D\nm1V8Rf/Y4JjruhdohhF6AzWOn9VQr+CmgLbkTV7y176t1xJ7tovrcekT8XAB\nw0vo2zZ1jQzYT7ZKcqEFjXDTMcwJ/13WphQdzduF/f13g5bue5PDjBO+UIYP\npZzWemi28txL5DD/Wo3AYbfqvOKGV/oiLUChHCQtAjGWra6WCHnV5cRU+d6c\nNMggTkUlvPeNbRlLNxmdyMtPqm0ovin3909e9WMEZixvucGAyVxCvo8RuJkv\nH6wq0tivOvz4wzA8Huwk7JkgvEsOT529i7YSmMZx6hYL9kYiYiFPtk7sZtvw\npBnUGghdey2/qb9e4yuXuri84JwehmhSFBbpUThalIroW5XHsM4ofZKORhvZ\nzBLY7J9IHe2ITOaaZ8RGlW85ZO0biNN16ECR8JLRn86K6aqCksMXgcNCkCyD\n5FpkHaPGE0towqxu0pG4LrO019QLog4kH+djpczCLPQoEZ1LCnTiiyAg6wZU\ndYmjEJGtKHPSu/hI4WI2x+synP9it/5lThMUs0xuswZTKLYPmsX7wJdk6HAq\nLpDsiyPvONEEN8+B0W+JaGnFrym6dbTMhmVkoMf8WBmHc07JbjNjDx/mzXrI\ndq88S3AAMx72b90h5A1KWh4ogyGxSNw5Ruh5IT+m26Jq1KifX3WL9hZxhhLC\nqlWd\r\n=glIT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHrQAWU26G/xxsypuyQrteGfIioXl/fyg5fQDwmvOeDaAiEApn/5YPaVee+2xZ9FHs9M0TV6wnrD1Ll/KoOVzv/i76Q="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.1-beta.0_1644839381220_0.566704680517178"},"_hasShrinkwrap":false},"2.0.1":{"name":"@superfaceai/testing","version":"2.0.1","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.0.1","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.0.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.1","dist":{"shasum":"d37702068dffc27328116e080a64bb53591f93d9","integrity":"sha512-gnjlFxbG1DKErkPCW10ogHc1dPbDBTA9wqvasFMytWT55z+lqc4qwx88RKY6O6YwhaRzJqWRjldtLUIZD98u1g==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.1.tgz","fileCount":40,"unpackedSize":170549,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiCkdjCRA9TVsSAnZWagAA+1wP/i/u7kd/wAKXbH1foO6O\nQvnCFvxwXP/DvwV3BwK+IBa8GKGH5mJqXPUaSCWsexPOdjtPBQ8l2wSADqm3\nqWVEhJYvlFmqpkwncKSGJmEtRGlyuaL/1XiaqckA3Xm81sVGUW0FfyW2ADA+\nAwycQLL6Ghfapvf7XYKMSnqxYCHHt8u+O9V93HD2h+ZVEir809JKlUE3L+Ej\n8rns/hWMXdPHcTe5oCosuHIZSN65jxjdplQt2P2i0OSQ53R9lWF3QmACsT+8\nWJgHAQ9igGPrL7KVCp9rswHMMV5VxB3Ni1ttNZugmw8KCrr4hcxQEtySz6AV\n9tZbSckqpCbqPggXKGu6YLMoCXgTCeZ8trty3Y4TwCCjdEQ1KBRLfq3qkKv9\nsxesYbZ/2RiFANQ7BBWEsbfL6STSCmjlwaNCMqfNG6aIOSz62MRPpTyxJ09/\nQSwbxux4j0QiZDiRPgqlf9pd0AflDejvzRUFp3dnGGUAfTB1mbJHdbvZY2+8\nCSy3yWlAJXX45dmQ1/QatPkyJ6PTo7ahQMI8xwjxFSFFSnXthSiZcWyqyHvU\nKAsefA5uP6iWZNBA3INpImmrWJztJJMQBNon3p1PhCF2CyxINTiwgZTdj6uj\nZC4JJzRH/peUoasQrbs+stNebhWV2Vf2SU10rFP4pXZ3bSVaYI2Bu2spbASi\nU0uG\r\n=/pzK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGwm4PvLZIcddqJMu/BfHt/IoF0+Ds3Au7jw5BXWDDWDAiEA+MybmrDmLnGuu53kHZdnS9BX2xg1Bl2quuqicaH0aN8="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.1_1644840803787_0.9925423908856505"},"_hasShrinkwrap":false},"2.0.2-beta.0":{"name":"@superfaceai/testing","version":"2.0.2-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"1.3.0-rc.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.2-beta.0","dist":{"shasum":"918fe8dfc6d76bb37c27e5ecf447edc3711dae84","integrity":"sha512-UHIWMbmZNoYiFUZ3rC5bH8fjDACZ1OUaF8y016BKeXl8w9Pg+wcgX9IhUZ+Z7ra+wORsQoxHfWzyJ/BwkKbeSA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.2-beta.0.tgz","fileCount":40,"unpackedSize":172111,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC5fTCRA9TVsSAnZWagAAFWwP/3aHNBBB53uVyLQ5eYw8\nIN78TQF69830ch53CIKpK5zF+qrWVXYD7nPd6OVkAFEnjktxSgsgpo9bn3kP\nLpnpOa3uuZHpWRozSqTyEApScnGPuUMZhfyNS/RGTa3fQa4mSzZa3Pp+tWIA\n9x7bq5mLW03h1zHU2cmW3NPLZH9rhEQfkcsZQzNZ2t4OeegcuaD6KGyx/raF\n5EY5IxNlvrXjKNGovljZGg6CulZYOsaLhROEbRQptfr6khUq9Ro2YmWZ7F+R\ngfE7enry/zyuVeX4Mep025oW60lASIm17gQ1PsA04+t8I3YnCSrzkgXHoss9\nUgP6HhePBjV9mDvOHozFoLoGUR9nVWp+kOC1vQkCpMrQUorUbyN0FM0dPSSr\nMHzn+SyP7JsSAvapMrqqqw5ITiynVauXBS8Gm7Lo4BbvmHelvdce4pUSMyVW\nlwxoVMsVKCeD3jEeE1+YLGUIB+zIfn0LWuDY+9/hTse0opgIwUzsRRpHKBkV\n0P6Zt/bAemvwqeZ4OhX1/dC/T/hvQW+mASRH+wlnivafgboYsPXacsbG/98g\nqNZRwQ3hVZRYRwzoyDZ57E9Q/yPo9Iq3l1cwHo0xrq7toSTrkMd1Px7uODjT\nF5W4Lo4PW537XGxGOZdkBOTGy6mqILXA6AdhJBC9863bPEDExg/XEaYffN/s\naEbO\r\n=iMfr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCEnEnS1udV1qOeoPMOLw3KBrP2RG9XI+uDuaLRAG8OrQIhAM9TAUmt91MvOJ1WSv9NiTOugN5kHg07MuSVpOGEnjCX"}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.2-beta.0_1644926931635_0.3900652102263169"},"_hasShrinkwrap":false},"2.0.2-beta.1":{"name":"@superfaceai/testing","version":"2.0.2-beta.1","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.2-beta.1","dist":{"shasum":"51643861d0beb3a1cf66a80008735170cc5ff7c4","integrity":"sha512-n9D2V85sVB4/0BawX62eUXu9ceMgvAxrk62qfaPThuFaMS1pPmvCIc6080fJ0rARlq17iIXrIPv7JdDNRvag0Q==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.2-beta.1.tgz","fileCount":40,"unpackedSize":172107,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC6rTCRA9TVsSAnZWagAAhukQAKUoHVtTkr1k/RQjlkY3\nu4p6VXsCoh1TX0ksst3oK4UMRhWfWYFUtzQFiIbgwGRcrX5Pc/kF1W60qAEo\nKxdVwmr9hQxYJ2rVUpFNfFdc1Wk/X4NRcaZEqS2B0qkS2wdgckku0gw5UElm\nxjtTAieawuZFkXLtddQ1HNBtx/iHbm0W71yxMDruyZu7e8HpC1gOmwNjTf+R\ni8sK6kAkdM3vPab3znqzK5dWyALXCHTbmxMn6157tIllIZEihtuO8kJEZ85o\nblhbTVUthKVjyuc8ou0JyJ+G1qOMjOQNGnCL3Ya+bbgQVh/DRsRFsxDsYhw2\ntmS/+iSRtOS+IYNNXBFdltG6XV317x9N9Jmb+ftgLPoBRBlD34ohQie1c+/9\nfC3W//Te3REr/wStEtMrNYHBgkYWhYh0VrkJZgn8QplMMJmlOFWIyR3a8HK+\nSDBbFmhCNzde/VhDvWMJmWCe/nwKNXMjBPPs5qdWiptDO4gwBkZh4OelJnfK\nd1jUYucgkbAPzyHseAxpVrRjFY71iLp/URJ4tqUWKeNdTYbiKbwpFlAL8SVa\norvRnsPc2Pmy1Iij/FR1aj3IL9Aw2PlWLyjJ8M5gkAU6HltL3wUHq/1a2QKz\n6+fXgsnsfOzEzcWP5y5DXut8P6Jvvmq58Ge6ipRPZPPi76YypZeFTU4H7VH6\necob\r\n=2woh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUkFhVFgSp3BEyrwdNgKF9TJdT7xwKd/M5hnqRj4SBXAIhAPQXDsgSi7AtuljH4akEnrQcsF086civXbVFl92KrHDl"}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.2-beta.1_1644931795170_0.7470314387809958"},"_hasShrinkwrap":false},"2.0.3-rc.0":{"name":"@superfaceai/testing","version":"2.0.3-rc.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.3-rc.0","dist":{"shasum":"0318f654b4301d47b8b0bb16a9a7b316cdf3a40f","integrity":"sha512-b2/DAD8wlVhXGEn8HsiwgPLa0skp1Iohng8YcSoojnd+QOSUAXDSaekBIrlvjyKJizJJi994vuml1ke0mvfamA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.3-rc.0.tgz","fileCount":40,"unpackedSize":172105,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC7t/CRA9TVsSAnZWagAA7WwQAJZcyUA29jufOsgk7JrA\nDTBEbV9bDN1MA1Mng1fdIFJKxrPXPvs05lsoxn9AcZ5x4fzkTx+wRQH0CBJ+\nycWMv3YP0urDd2tTd/Remb8Nzm8YZe9DCXDY15jmoQZ9990fnCKeFn4kLuBy\nYVFhGaY9brqM6utQHatXl8iYfzS9JU7aXBoPK0KvUNwkhizTiqxsOj1+sfGi\n1/Nduv/x6ngm3wmTyUdwJeiWFI8UHjtGO85CfE5+JwFNa9alWOWz69BuO0yw\nVPSxWG6aduq/hNaUYAr0pLTi+ygB5XwkbmJndA0GnkaB62Im2h1l/9ZBGdc6\nAbmJLcUMqTPRcnhXLcPlA/Piqhw5+zZ4wHwxOfREfJJjHJ4iNX0xeUdQkVj6\nUyRXu0VjBrbfcIYZxG6dzRrI7/vDfnXF9AqMFKeYZ15FFqoNf8ydhfmRxQYQ\nuylkq7YTsvyj9HJPsTVL2XbbWtI3ep8j10a6zLIwocsQIhR2A2qF0RDtu6Or\nBl7l7Tu2VB750SxxEUOLbJh2OKWDkcFWUPWVRL9B0EhonIQtGNhfG48WkGwJ\ny5+lq7ZSn0PUPRGg8ssZyWP/QmJwC+rMlAdcCT1PvP719jF778TCKM/7jvWt\nwkl8Jvi+xdMOgsQI6SS6SHrAKKOwogEKF5MT75rsJarS21JCNdBCwBbN2D9O\n9Yfm\r\n=2i6L\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEOD5CDcpbde3O5FtSVDnpfCQZ4F/Jvx3olEENCpNDRCAiEA3NapD852BuCEu57JFs0U+1FlYCJkVAnti8/zzeKoz2M="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.3-rc.0_1644936063184_0.9639288647514956"},"_hasShrinkwrap":false},"2.0.4-beta.0":{"name":"@superfaceai/testing","version":"2.0.4-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.4-beta.0","dist":{"shasum":"de23d31cbb712d8b1c3e3cb13bce919055af92bf","integrity":"sha512-HDHix0YW7HAOKNA8E8t7JYfV6Dr/5A+beqpXsVJ7EFuEt6zRfFpnylZbPRMkh1EWyhJ6VDjwZnyrBrX7tz7K3g==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.4-beta.0.tgz","fileCount":40,"unpackedSize":172107,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC/bfCRA9TVsSAnZWagAAnpEP/R99XWbnf4Is1OrO/1LR\nGtsfMtMLKJQVfah8uR7ll5SRx54Qav+Xmcp4+nf7IeYnSkB2jSfJBu732aBe\nUUwJnU6QdrUADlv+05EFMI8Ii3M0FQ2ahJj38ive2LYtggA/XZf0n4aphqKn\nhmf5b0niBo2NdWPvQgJ3Puh6IUEySoahBT9ap1zj87aRVsQcHKrpN4FpRAJp\nhgMMgl6ErHUT0H5foPgSzmHE9h6X9h6uiNHrW7fu2sE8pWTmOcaq1pqdz+si\nGYFrzywfKKfbtgZ+9gDby0HzaHFpJpn098C/OjQl+hC2UiRcXLhILwD2ERXm\nWHYcUOwPnLgKGGT4jkhz/9lp0jNqdhLr/BQFodcgoo6AztLDkGFUSlkevXWB\nimJxfEpCgVNfvehF5YUzBtmot7R+0jgt0TlKWhEfJP4w/nrhsgwK2w5FMCfd\nhpayMu99+ghnRhTSKVAYpfnZt/T40XK+icM3/f6ZB4h2baDWMjNhOihhCW+6\npY+bsrMtVqiN2T78PTJkA+zl0HTYIs+8qh5U8aUH6ut+LWUC7ntS94dllPqy\n+U/mzehnDmqeAimYEWPJAtEnY4xIgEIxbAOBU/hN+dHB1zuz4pdGW7xISSGO\n8bEiPX521yN834SGoRaFH7SNAKuQO3hDcSboatn+lI2Jc6U1mUhatC33yTtA\nL39p\r\n=KeJR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDA1EPd/K0PqY0VU8u8mCN9ns2rK64+zwHbO+XDftwXlQIgEM1KDytJXUn/MXWcPfhTh0gJOVt76/ReB/Y9oSXSFIo="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.4-beta.0_1644951262967_0.7729199335742767"},"_hasShrinkwrap":false},"2.0.3":{"name":"@superfaceai/testing","version":"2.0.3","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.0.3","dist":{"shasum":"bff8cdb15686055d8188bfbbe31f35416434caf0","integrity":"sha512-aEQXa1rInbK6dBZoEmzocyYpnqLC/eGJFRlaJgMTPCu7IHKWQde00IxUWEXJ2g8M7L/kD+GIwUUVF2BOfrewwg==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.0.3.tgz","fileCount":40,"unpackedSize":172197,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC/k7CRA9TVsSAnZWagAADK0QAJljtNM+ixithqlHeM0F\neIJ/Je4ozWhaYIU+RImKOlnsmeedSkeNNs8/zODBE+edXG49Gw8yW8bNgnPS\nZfaDn15c3E205eSQ1s1rmsKZDubOCr9z29gEp57efcJZtALpD8YEqpXtUSa5\n/qQ6fT7a1xENh1iRfnIM//VkQrG28NCKhR+xNOcLjDmRBBcesk5IzobBL4Hf\nQxXcBlPp0DCqbPDYngbQv54IhxeQKB01VPJlfIae0lK4hEtgl8X+rc0NtD7w\n7PJ0LNCiWewS/u5TUkr4WU9ENeEr1nE7PPYIKI4E6dDVx+1NH6DBCMh5cHdQ\nk30OGttrJiTW6C78eXNsWqA8AiF0CoaPNItu406Bf4b0jTb9PAo01dRi12nO\nICxJJR//IAso/+vcroJFFD5rzBKTXo4V8KTWA4AsHlKWfE/hia8yhR7f0YZU\nb03CavNMt528A9/cDFSiSZFtIHohxZQ5Tp0hB3Q1DJJ9gZHh9budoRKC/f/e\nHSijA3bRsa5HHKdfjm2kjy04dXT5MYnSDAJiMVq4Rxr0OZBxq2ieTW9s288B\nfg9qCosltUlUfk3Za25aFewcHRgMx44wy6VfdJ3lCH4MFKBcT1UBBpoN/gp0\n8Ljzd0+rAx3koZX+JzYWUBfSkWJbmoBDhrUzwGODmdTFgoh3rfE6ko1lR5nE\nEMhc\r\n=o6sc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFh5jqSVauPbjkxOTcjvQAtrNWCNoeRFSNrrKJIm7PKjAiAA6ZNESp0W9iSHpi6Ko0BW78eOmJCBwCR2x0g71S7cgQ=="}]},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.0.3_1644951866855_0.6860816481027017"},"_hasShrinkwrap":false},"3.0.0-beta.0":{"name":"@superfaceai/testing","version":"3.0.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.0","dist":{"shasum":"df188fb1990e6c8764d27ab9f07b48ca07e206f9","integrity":"sha512-hfAM0tSwqI2L3flj+9RKrA+o40xSks10uZwZRcJHcpZ2PX4DxkftYL+ZfVT5G0e/cqhp+lYbJ3mYN1UK86zJqw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.0.tgz","fileCount":44,"unpackedSize":173553,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGsY4pBtPRRGFLXThPIu2Ayrjrq8OSBWPstHvP7o2cWkAiEAmZvU9P94PBoqh50NvRHpPnjjK4eE7SweRh0iUpiCF4M="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJin0eaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp9HQ//Ul9Lnli6GIofULH5j8UsQghllwfB/6zrXzUXJX1+29Uj2WZT\r\nW02nA1cD/noPPshcg02PuWPrhjhCcrYllYXMA7f2JxwlpL7dV7kZukZI3lh3\r\nMDn4KUrZTGAf6Z4gIC3si9Ozitz6icf5kgg0o4AK0zWuKnTnac2lW5zGmNry\r\nSs/W1HAhQDwli8pGwyJc3cWYyQTg/EdB2OXtWFDzNqVhrMvxbklZlRqUfraD\r\nELiKy2wX6j2avQjix9j+4FSotlAJshaElyFrjKfEyUKz1KVZMz6sKc5zRTGB\r\nWmUGBIocJMfSh5RQvUrk9ONUXAUr7gJEjG8pdjdRSwMprgViDGqjg9HyPklr\r\n1nGJNJen+v8px+HGwXraMn4vtfTIsi4rBlMqM8kwYjEEv+61D6eJxqhixfZL\r\nX0R0aCb87NRAyPuxv2/mzpUS9+QHjB3SXsvnP7o+t2FHX9l4CDkHwLlyLeTS\r\n9+N7ou4t93IPAwVTorm9ITJJx3mPx+RsuEfFR4bCNRBOCZuegzrKX3wCQzuc\r\nkp/FATkUFtEgH2IvqxRFOnHf9uW8hiczS/2v56IBgyDMWmgrl+J6etS8lFpb\r\ni+VkshIhMfd+ieG1ENfW/OGRFwtFMVhZSENrh/i3JiBYNNnjvzdy/zKPPytW\r\nMWNrtEXTj2sfbBBiNUj33oD26Th3VTAc/3M=\r\n=KPcX\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.0_1654605722082_0.8252735851374982"},"_hasShrinkwrap":false},"3.1.0-beta.0":{"name":"@superfaceai/testing","version":"3.1.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.1.0-beta.0","dist":{"shasum":"b65005efa6af8fb85ff33a406945f82ee26d7fec","integrity":"sha512-9gN/rMH+nGxYaY20gZFP/JOcJWpz9eP+N2CoGWuH6nHGiGtzL5kYU4CFl4occ7u8EVPqh5+Ai/BBC5pY4qy8wA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.1.0-beta.0.tgz","fileCount":59,"unpackedSize":237642,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC9rKg6xi199OaA9elZPemSzCZQQDElpDnpfiaMhNuPzQIgFsuIl4ljNgpBRorKziVsrwjSYw7+eyoPNo/j2x2V4z8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2R1kACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp/XA//WYHVkbqkbhn/tMKEqId4yR9RlL4Z2V89fa2h50ZXSk7v9PKX\r\nZVF6aEAmLeS9NDgZaxC9Nc6VCjO/24W1Y2IcwHX7YWDYlDcPVPK+4BtLjmiT\r\nlSPBYDbKsJaGgceDEKDAIa7F04P+NI+1TGOk8BuRzKEipn/uSJ2PB67/3Uks\r\nOyCeynaaO6hJWfsnImczxdmgGuSFjL6WlK5YITb0osK9pQjoALWQr7C3b8UY\r\nKEafWN24utk+uU8fUYYuITaAlMrKlQUDH7uDCIl/HAF4rvSfeaMGBT+9j91/\r\nK8Ee/tHWiIBZgKnmCGg191IApXzRC7lpVz53Ej3+zHzs/x3d5VTN9Fg2rpja\r\nvnsiwLfFrgZZxJmXEVoKP9Yx9MGOKjmuGAeTEUpnPk19G/0i24c/LtQ4B8nq\r\nCkrlNK/Vn+9+Wf11/Lc8XVwYT40bZnDTcAX5rRvrxF4hiVWe/owZCn6XufBN\r\nKkO1E+fOr6XbeOyrTiljXN/FJE2K2SDdrtKInyy+zCJArPZUJ8ultZFFA9Qr\r\n+a5RSb+/0xajaAn507S6frM8unNhVXfhrWJLZWgECW9yeNTnDgl4Xg+trv0v\r\nYFnZXbqnoAsChczbvBYb6lbW1CQ5tOSo/0Sb16/+k73X0tN87fd7Rf5vH/N+\r\nSy6y+6OU7/mVQTcuNInZSO6Z8LQ47rIQdPA=\r\n=ILp5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.1.0-beta.0_1658396004295_0.2853628078453574"},"_hasShrinkwrap":false},"3.2.0-beta.0":{"name":"@superfaceai/testing","version":"3.2.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.2.0-beta.0","dist":{"shasum":"eb7b141d64dc4eed886bce5dc50d039a56a313aa","integrity":"sha512-gxlGIcXZ7Sq9ALMx+gXBx9Hkh1LifrJ0te59Ud3aW3owYdiYgwgCJCrlHMlYTii39rVF5BwTCiwR/z9YbWHJCg==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.2.0-beta.0.tgz","fileCount":59,"unpackedSize":238040,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEMbx9MpwRA/Si1e0p5MREsNDfRG9rFebnZLkepZXLFyAiEApzxf+nNdSbn5mjvS0YuyvBvk1bqhNNUxqRRyg/Hrmos="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4AX6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFuxAAnrxL1AyC2aLGtxSNLur2sx/sU+qQkPzd663FmH5ONt0V6wh5\r\nvatgAiVGvgELQDwn1jm6F5qu2Ds4MUi+02tXEMtq41ZyIW/KWevmD2QweBuG\r\nzXfOXlWuiU4YopaCsv6QfbSJujn/qWk7LodzaRkiC53A+8w0x3xRTSK5529H\r\na/MyWpniaodVwoKt5XkNuVTTh5vkcG+/IBRBMAzbwQ1O144bA8ZHxKvbs3pd\r\ncfmBFAK++/lyrRXkgEoxT3aLGohMzChDInpIyc9wRWlT7/3uxwlyLRyuPCp9\r\nzGj3TmPf4WWYRPj1ze3jCQF00dD+wFDlaQV4fIlsk/GTb9wdPCb1LbPvHS3e\r\n/dDR/jrCJrlU/pM9P4Ezp5fzRje3H7GAs1H2hxVJivd95KZPovO+Hi6mYdTt\r\nQJjNJnRJr+tz21/Gvw78XZtt2vV5o+fyuZjxEmFpghNZ0wHC7WbA71PxPFz/\r\n9wvFpSVQK2o28hhthehSIWE4wlDNq09ixGv2A14Q2lWUenr5HNHejqhFrY9/\r\nOMRRfwf1yqcd/T8EareNUYOgBYZ5dLuJ8l+vZ7TkZLryY0Fscv8svwpUqE0D\r\nUB7KS77VYBsK9mu+ThWJkvbk0xthOudgW1frWJgowe9oMd0ixdFqRIL+4HoD\r\n3aYMy/3lNNUep36/7OILH756ea3OWfP4nY8=\r\n=Qmg2\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.2.0-beta.0_1658848761819_0.4590931986230946"},"_hasShrinkwrap":false},"2.1.0-beta.0":{"name":"@superfaceai/testing","version":"2.1.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.1.0-beta.0","dist":{"shasum":"59eedd87c1c6b388b4ce78ad10b3ebd3df9b6240","integrity":"sha512-XxJkW3TSENpOkzLymlNs8eBNU94sU2tLSM/mAN7yxEGGDWAb0N9AOx2/jCWvA+pbjN40kMvjGgBnlGFHKXbCng==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.1.0-beta.0.tgz","fileCount":62,"unpackedSize":265829,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCm4+KMDIFZPI7vFekievBBmkjDac49wGpNIz1sXDDfLwIgf6YwQoNwouJdd3ULecXfCEePoltXx6f+JP/pTLc71+I="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/g7rACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq+Bg/+Jpy4nvPStJgvWYHAqvZC3nN9yDv4JDobmiKrC6pCLJKcxNcA\r\n2NH5o5KufJ1/sb6Cc5xKkp2EvA8+aSc1h9mVBqYVt2K2ztzf3aO6w2slYnLv\r\nljR17DOuuM4EiQWpak0n5dUoXL56cEM74aXbNEdDTwKh3EAX+fWHup5Kz8yx\r\n+Hmqmx9RuIG0UadcXPqI0fUE+rcnwBBNC3sphKa5ewYOAUZKX0IQmpL7ItTc\r\nCQ60GD8XPhgy41uj1MVHJC4uyj5XVXnZEy2l90LcqbFRsfbahHxBkyTmo9Ox\r\na07lpCnHveeyuo9/WeEg/PsdFOHFNLL+NLG/HpVV6uT9HRT1iLgYgkKSLzvR\r\ncrIHJM/3pauXqqHrFW/+iBhnkbHZw1eN2bdfFfCy8WtB+yrj+WMxAZ9IRqpV\r\ngfdDRviqMuU16nvtyb8FUwIzjva7KANtiW9CXyjl2rF7ik11WncrhoH68o/J\r\ngFAcInLpZHTRijBFn0ME+Y85kv925AcQPf1dJ5CwnsexKZdhiCXYqTVN2Scs\r\nsHWJTTYVtIM5d2zhmXBnVosEQaY+uGJIGLfqZb5+u+itbWFZr3f88XvABPdz\r\nXSSOEEPa7tUB5IR//UqWCQ6E6/oOX6X5EKsKM9Y+mnhRXvAm8VgdBjRmET/N\r\nIK8MitNeVJjVdOIK2T85TAz2qR8Ghx2oImw=\r\n=xSRM\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.1.0-beta.0_1660817131374_0.2665828562478958"},"_hasShrinkwrap":false},"2.1.0-beta.1":{"name":"@superfaceai/testing","version":"2.1.0-beta.1","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.1.0-beta.1","dist":{"shasum":"b5f090d5893e26c62110a552f69f2fbf9c16562e","integrity":"sha512-xZyOJP+XL7KdSUwZEP1/ZSMsZsnLrmx683egxYdbcbdoGTCBRmJ5KPE8jKmxc9RoFJ9G7lFpKUtWvC/C9AmoUA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.1.0-beta.1.tgz","fileCount":62,"unpackedSize":267471,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDV9X7V/q66jP9ollfpxFtFiQhcX811ZX0T7b+QeVv7CwIgVYoM84DYEKCYtFhLZaCSUnOf4chdfuTjLg5qYkoeHF8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/iW2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpuqA//Xqzwnzpin4lSGVx8JWZ2u1r6WZyUl3uMriaAu1+14JMxfEEb\r\n54tP932SFcwj2THLyMIKCH8wAMjT0ZiWrTMU9XAd6Kn+A5akLuSkzWqPOD/c\r\nGRnXrjxDmDqOdZwqu342l/j3Txh2Mz7dweFEahSwtASrd6nZWkGsPgNV6d5b\r\nTrhvGJ7gCyuyB57KKHeZzCJh/G/M1DPXM/BWEp95XNjHVNLNllQI4V3uz37g\r\nnDXWKeOCr7SMLkfjTGdOhbnoYXMhHzULOg3vnt7sgh1D0RlEaGtQwGTGEGLu\r\nSjcnSjGb6T0scycN12A1Y8ZHlKBAIL2GFgWJzfxLU1TozVXc4+IcG83ud8L3\r\nJiPknFJkkousTZTgUjp4Vnh81PshyNvatfAxM7RN3krve+Ootghl/xZ36f4T\r\nEfO3hpDvI8wsaLpDR5OJ9kC/mER10OlwvoIBqhIRKwBeU5v4IEOg5uq5eQvZ\r\n5PiGXe2yoMVOtn8SFM8I4uet9iQ2bxTbtK5LeP7+FSFsV/jga4QyGWuM2fiO\r\nTze11BKFN3KPAG20ZvD2y+o21dv9MyZ2tAeMKjvK9Q/vRUXErzpPkGrc3/j9\r\nHSQRWO3ltrJMG+LAnIXmi+Njs4UEMnXFlixtF84DZEBk2AdQ4HcZkh+p0BZL\r\nIFj5V51v8UfA4IuH1NxXwCr+z+r1vEF1Hsc=\r\n=lqlZ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.1.0-beta.1_1660822966026_0.7412123223828848"},"_hasShrinkwrap":false},"2.1.0-beta.2":{"name":"@superfaceai/testing","version":"2.1.0-beta.2","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^1.3.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.1.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^1.3"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@2.1.0-beta.2","dist":{"shasum":"41cca689468292236a11933220abe004907c99e6","integrity":"sha512-JrBUEtvRnKcFRCtmNTsHwIN7HtLVoF2XDS1DhKxGh1EY9zfbgns2TaHC9t3HsmrtzCYOI5kSwMZTVxKl/PtfAw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-2.1.0-beta.2.tgz","fileCount":62,"unpackedSize":269632,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDiDA03Sdfa0K9YarLMsyDS0/klOt1hgwqpLgRoPbWWLQIgV2/m5e8GKCqimheNNxDlTTOzinEJg6lUubYjqxn0mFI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjBf88ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo2Ng//SxzxGeGpK4eyXlzulUkzNzIikBjb1+peMs/DzdYJutTZ9bFA\r\nkgBar7zmNfctDSUExBtGuleI2UbiUIPRtpM+RxIf4GJ2vEXhVPM8ydPfeUea\r\n6cWBnSMwgKa28w18FbdJ/3JoN836k1DNio3L42eb8bxDNuSESLtyK1SXLUiT\r\nwXZyxzeO4aZSqIIp//gA88gsV7AEBrdcCa3Gs7OOJPXvC9DuaTvGcwa+qzeI\r\nikFC9kD2oI9tQ6Yww1n1d72td4lY1tMvtOUp+B/jAxAIOj0zJ5b2xwxSLSnU\r\nlXI0AIzAPZXsnM+Ms1ugw4qkVyFQJ3X9D5hoo2C2Vi8mKvJ9zmaYHpzzACXX\r\nNho23qU4Px5z9n04D853FR9OQBp+BHvhcHrB3S17OueRGZAVKiCYXiP0EQXv\r\n6JgOAJFpb6GreUcTnGEsBgvKMe+J37qMaDsKSfYZTcgzSZqLF61W1OVc0oc0\r\nMaX87R9Pmmfe0PEOsjcyMK41/qpfhg9eOKbwo65B7qmUy5IUx2+Sk53GHgXO\r\nr4YfkfsPkFizOWtMU+l4Ylz2nNiVbt34QqbQrqQ5t5gI6v6gG+9DT+ujdjIN\r\n4cPw65AEEXnT+7/6Ccw66+NQxuQAvN6WEk7t8fWG1vJzbPwK7JUeaPzch8kn\r\nxgXd0ZpikQZzV8CXrc1Jmj+vA9eav6op0uI=\r\n=oeHN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_2.1.0-beta.2_1661337404298_0.6380617861514528"},"_hasShrinkwrap":false},"3.0.0-beta.1":{"name":"@superfaceai/testing","version":"3.0.0-beta.1","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0-rc.1","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.1","dist":{"shasum":"87fb50abd94cf7daa9659badf5e8c4c84128ffa6","integrity":"sha512-7T51frST0fb5EgybWY4XueqjuYcODUQQDegUKLlOo1yjPsWS8NjRaL3bqikBn2ogJNVEdSmqTGfzqzupU1xA5Q==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.1.tgz","fileCount":95,"unpackedSize":225999,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDc/jaTdUudzHuiLsNoGKGLnAqEOVOwOb+ygo131yOyTwIgGNFZUqjXnKuKvQnjB14CAWMzH1zoEz6Jj6mB5792wwA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjBm2+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmro9Q/+KUH4bGGDZFoU3pbVwe6TqfyGVqcdp/sbQDgU0dtNh5IL1EjC\r\nHkxOHK/Irc6YI9yCeIJG8M1cUUwQ6xjJ1b790mXx6h6nIGUzeX/w5SHjXdRv\r\ngKtJklmYzvOdDOFWAvr+NN/A/J85K1qn/cPn9FQ+z4GqlMC449XU0kZUGrZH\r\nl/31+Y+rQ/9EFMXV8zWGjspI26jiw4fBBDu4yb9UI7ssovLzqAu0ASJDaMLT\r\nGXMmeRYmenfgSsoQyBaIXJDY1iQtEBNM1yzjBmy9gCcxa2RHbuWOfAS7kWVp\r\nYToF5fPIz0qg8y1ok5yclBAVZnoo8jW5/sgUErKOr1jHFfTnbRog8r4MUYtr\r\nfYXdriiV+d00dEfFrkivCoPXWFGfxTD1XH9POZEWCD0fD8K1hxVYBotWlihU\r\n80K7FyT41p+XGYHiXORz17F3u70c8AlDtKo7zF39AkYsiCgA2iFctHE+9f7b\r\nAgB6OcXXRs3U80/1Sr4SqXEo5eUS0C6rkC2ogzVHiqTWMdmGqhPdYYyxCYLt\r\nRkAgzj2GYl0ORxDokF2mkMSfOf8Z4siXm1gd7qZGIcHpiTgriysZhUtgS5Zn\r\nNVfcuHNZ0uHpMifB7IPOOxog8W1B2hGnnGRmLUKRwo8yR/ZrdhAfJaUtg2XV\r\nB+GGIP/R55ptirZ5qsg9X3yN6ZeN5y1oAQI=\r\n=vpA5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.1_1661365693811_0.1399002592027052"},"_hasShrinkwrap":false},"3.0.0-beta.2":{"name":"@superfaceai/testing","version":"3.0.0-beta.2","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0-rc.1","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.2","dist":{"shasum":"650110b6de8da1720e0612d6629ce1739e6cff88","integrity":"sha512-DwL2Yf4IZlJashnHpA/Rtq8puceTZKOxjr+BmppnWpSdpycrcKsemRkLJVdfVSnowIvdIIE1eib0hck19wb7Nw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.2.tgz","fileCount":98,"unpackedSize":230932,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJc3jNdFYNlT1pLH3u8MAdih85GneTA0p1V8vux7EcWAIgN5AOCapHhR8g+Nxf6YISIzVPd0S0ri7X0LiMi8YKbEY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjDKPWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoWEw/9EnSWvWyCDuOO+VIyZngHeiYX3Bx3frkltXGbt8Y/5ZKnOutp\r\nXxzQfhIDvu0Apzw+4lKTkOfO6S0WwsLu5S+QybelCcU7iNoyYeR9xAGnrmV3\r\nyLUlLWDxRCXud3kIux+cLbAMTOkZPIIpX+Xpyb8dlKoX8AKjqIYRMdZ1iBl4\r\nndztbeuuY+foFdVuxJF/5L+acp8EcPyVwlUP4tWXk1KkY+I73CTEsNKCV3i5\r\nSgU847YEV4awUHedtVlrEB1FFjBKI9wDvBBbNgMnxvy9cHVTtRS89RCUVBiS\r\npcJiWo9gMPQl9GMhtvh+ScE9cdl5TGCo/t69GMA3okGqnDrZC6K9/3E85cSo\r\n3CKOuZbCSwXTTgdlmjVjtb9OMzPMZXKaM1+iXHJuCMW0+tvSyFc7/QtKvtTP\r\nKb/mojkNSEBkm1/QUsaohQaWVXWCkrxfreJIi9Mw8DuVEBOJKWWGNgz+GMVU\r\n66mBmXiyzmY5kf74KUuUcacUBa3eIdURa/peR1Cm0UI+qT78lUh+wcKfTkCl\r\nlexhkACy2qTBiE/W5wjuhdGSfLXYP9o8MKoa7xwjr3RspjovjwN8shnik6LY\r\nmGjMs8MnNqYdMEijOzsjCjYR6KfH5+FXtQWCLLNVXT2wWgOb8iC2oQywEwtm\r\n+rDG0zJkr7FVfsqFtdEw7+SEB66FTXVQDw4=\r\n=ym2u\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.2_1661772758288_0.7999280807318352"},"_hasShrinkwrap":false},"3.0.0-beta.3":{"name":"@superfaceai/testing","version":"3.0.0-beta.3","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0-rc.1","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.3","dist":{"shasum":"d51e8b5e1f59ad6244218923750581ccbee0b059","integrity":"sha512-UoKW0tzWVo+1y2IY4eA0C+AIgc0na2OCuyc+tvZUneumq3Hyj7hE4YHgSVz0VWvAew+DVVDsqaVfh9ncPzr8Dw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.3.tgz","fileCount":98,"unpackedSize":228597,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICyqVVIt0EZ6cQXtqwJFWD402yZ6YblShaV2I7VAsc59AiEAoJbdC9/50EN5IOrWvtwra9z/N5ltDT6Bx5GAlgh0H+A="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjGFjdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpV9Q//ahzxNp1YrioA7DuVJ5aD+2PpQqHvPNaw5gDLVsIEmOOpM3ld\r\nf4TNzqskag5Yp7C/6Mbt2M+XRekWUMc+ZjanT9Z1CPmT17d0NfC0MLHxkJYF\r\nPS7UsuYN7P0QF4YZabqaGz55qh/fVqH2uvnvl9frg517f8sO0CI1BUXc+RXP\r\n4M9EseTfNsdRukWfWRsZai6anaqwXL8KEuWx659vEyLwJFiKI9CBbroxT5bi\r\nyAoWL2rBq3RippD5aDx2rNsmLoYfz8lzrkqOWyO7ock1yYJ0TsUHUIONiZy8\r\nRpRBGgBaf68+khixOldnG0clbkyPrxOi5+AhXl9FHnOyy2cMCjnGB7W3F8qW\r\n09BKpdjM1eHGp1DFzA8EcHHOdj+dINaR/EQ7paGTx/XCV1gpNL4sVaiQIlTB\r\n9iKCehLSxjRDaQ22arULraQPDACJtinq9vx93hiZWZ0a7OmLX07eVKLa6u8n\r\nxkykgs2zsM40FN3S7o0Fyv2GfAe1LlNfM2QNAXTWADOz2aplHwy49IAkD6fK\r\nV/fvtCfRfWylC2uZ/yTsImrRLtWLxcwes6N8EntIIQtvxh8OzlVZE6wJYWwu\r\npbT2FYvMQAIhEo2t6HcoNj1DYbrQzqPDfzKGwI6T1pp/My+TFfuOxJtSwlBA\r\nQTmQEsH2z03d9fpcGvcEnck9ANZBQLBve8Q=\r\n=5E8L\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.3_1662539997368_0.3243030725531373"},"_hasShrinkwrap":false},"3.0.0-beta.4":{"name":"@superfaceai/testing","version":"3.0.0-beta.4","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0-rc.1","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","debug":"^4.3.2","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n  }\n);\n```\n\nGiven nock configuration is also stored in class. Property `path` and `fixture` is used to configure location of recordings and property `enableReqheadersRecording` is used to enable/disable recording of request headers (This is turned off by default).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates nock recording and UseCase perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  afterEach(() => {\n    superface = new SuperfaceTest();\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        profile: 'profile',\n        provider: 'provider',\n        useCase: 'useCase',\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` will initialize Superface client, transform all components that are represented by string to corresponding instances, check whether map is locally present based on super.json, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)).\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic with `nock` library during UseCase perform and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings.\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n`DEBUG=\"superface:testing*\"` will enable all logging\n\n`DEBUG=\"superface:testing\"` will enable logging in `SuperfaceTest` class, its methods and utility functions\n\n`DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n\n`DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will enable logging of replacing actual credentials\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nA workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.4","dist":{"shasum":"693b3f236e26ccf5a71462376bea1b1de5e8f875","integrity":"sha512-nme396aOnaGi0Coyq/JzVDBX0XUPlBfXvpSZ3e5CqjCBxIA0JrTI8RN/3n8L5TYyzHWo6ioQDjjn1cAW7/cESQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.4.tgz","fileCount":98,"unpackedSize":233375,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCjDpt0RAD+3u+MkVNyu2vULRzG8AQ8fwTlhgv5I8gaigIhAOnHau2+4X0zRpCeMvhGYbO3syEP618s3WSUmnXWWLrp"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjGGYkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmptog//ZlOC+TOGm+QJQGCQ0okYuIMk/4Yz8upR2VnnL6Keu0pdd7wB\r\niykbLn0yGPR23uZDiasTaeVxyD9RZlHsWkkOmnQMOvuRX1AMmc8FY+ErDUED\r\n4hVKKupT89qPQ7OtdHgllFYeZ3jdTRPugKFfpWAkuJBewIqQHamGBvIYecNR\r\nkfhaAgiUswVx1C/Y1N510GbFa2YXHNiPjV88gR5H3NpAhmnyLRMSk1cmEMAp\r\nfVfCFhnDk/6/GgAP2k+EPddVw7lsOwjpKv/yJ9+yuzo82Z/zf/l7zDwfQ0g9\r\nHXcNON4F4rKPfJAp4Beca9OZr42Ns2Pvs73nkNfDTIalerFddFIamJSitXzX\r\nddNoipbazRyT2cv6wPX4Z/z3Mp3aOnd+5sGJvh77Kk1XGktQXFR3pZVA91h8\r\nYCB7LUIO82SNfFAKhrtIfg+p8QmNnAcryBrQOaVvpm1HAoxxv0ouf1c/c0HZ\r\n9i1WQ0/ZiYdW5fD/piqEs+Dt+rqPNyZ01fMY4bF2lHdZTZq0O8ZNRIMZOO0d\r\nPHLM0rWwKJAIYC1cFwFrxeV3x91TDLOgXSEv9Wy5wwYupYMxRHpdBt/Qi1Am\r\nwWE8T037Hvbsw6DfvC1S3a9T+cYNn+h9zANNuMDLSNWjAp5Az1YjGnxmtOpW\r\n9p6FcPyCVgkfLqH6dByfoMKGliQtCyP9Bms=\r\n=alY4\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.4_1662543396458_0.5061977869160277"},"_hasShrinkwrap":false},"3.0.0-rc.0":{"name":"@superfaceai/testing","version":"3.0.0-rc.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"^1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**. \n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture. \n\n```typescript\nconst pass = 'secret'\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password']\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`. \n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of: \n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-rc.0","dist":{"shasum":"5c7a414ca38778cd947597b2c6ceb77ff36d6325","integrity":"sha512-oGgHcT/gyeb+0dX3abddu5qmOupSFFL0FF2oLi5tT23lkfD1Oxq8vwDZCEBaydJgbvrxX3cutNHtPV0tIKkNbw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-rc.0.tgz","fileCount":116,"unpackedSize":340099,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHwtVtK4hQf2HOJfgq+fg62ZitOtJfWb840hD1/NlOI0AiEAvo2AL0x3Ap6oTxXjSubLjDPAXSoqVDVGvSQb0YNd5Kc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjIxK+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrsUw//XKQw4P4il3kNhIcnXud1tyP3QNnr8n04cN3PjL7cOdOJAOMm\r\nkf6nakkGD/v7fJsCTi565jK4MOLUtwfQursk31c1dUOKSE4yWMyN4Je60ZNG\r\nznAT6hC5XycdIHqHRAH4RxNL8LPB4ez0kNO6VDwM9q/bUtQHLU8M11Y/uW1R\r\nY92eqN2AaqL3Lw0hm8l0cJZmGJbEBa9A4DiIxBFnwbR5BGZsl1HGND9JcZPA\r\nNEsHwqFRkC+alf9p8y++ud75M8yGkEiRN9S5PV04xchfkLggzXjSpiRzkpJS\r\nvMY6RrYKdRIIzG2wnl/vUBy1IaDoZMsd+VYXo/kOGDyEfxaiDho3bfZ/qX7h\r\npG7B5kulo+egG3qgx5ZGexIS4Qomrh210BxBoTRuEHAqp+/tgPCvNv/ar/mR\r\nPiGC3zgGqRxOE2x+Zuo4zHKEYr71fdsL1kqtKrINvdr6MFyVG59HPdgbZxse\r\nZdDEcz2nGYtN5HD3VbVErfUmk2cfcy8dOM71hKu9b8JFY2hSKQZFiaEupPA/\r\n7e4FrDZNK+npLlBvJN58HQgaZppu7UHzUh8ugcKD6+N9ZIN38kzHrOr4nxQX\r\nRMR1wu09Ft+U1m1syoqfJJi2iudqdsY47p1zWpaT5jpCuuEztWiR7hvlj31G\r\n+xxA05y2+HMCxfYtQCa9AnpreezVkk7x2Ok=\r\n=yIPa\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-rc.0_1663242942324_0.6623139268479799"},"_hasShrinkwrap":false},"3.0.0-beta.5":{"name":"@superfaceai/testing","version":"3.0.0-beta.5","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.3.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"^1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-beta.5","dist":{"shasum":"6b45e654bedc53016f469d7618dbf78e5187d8ca","integrity":"sha512-34N5XnBEvW/+cRD55fxMpaRS2N9jrTzWHfLq7Mograk5m39RUjt5Xops9mzO8r/vqSSCYBPTVpIJ4zhEmBQ5GQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-beta.5.tgz","fileCount":122,"unpackedSize":370189,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEjxkHnmUO7ZnEUuBAcK12X0kzUZ0m2Hi5Gk2pFjZRwmAiAQdyoSxkYG/6M5iKCyJjD+uPztCMD4MXSwGtL7yx3DcQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYAFwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrFoA/5ACWDcFcNCUWWol9RQY3L5zIinIJc7VsxV7o/mC0hXNvIN0px\r\n0VpW1VpT/tpm5d92gfXhcE42jddY23hjfBVMeDA5Am4/cKJHk9MlaDhBK2I4\r\nsg9s6e0vR8uvb+KKh2OIV1iKpghLjvNvtIQxyvJvTre9aOUG4dchwx4HvS7i\r\nQZenK7TCS8lwEsG1X3aZTfR7PiTUoPTAg2Dh2kYPSxFeJsxsjTJ623YIAdWk\r\njMVgIbsLPaRDoggIXQ39hO7Urs8ZKrFv4u01Y3ZGzTypYZIhaXm/7oatUKqF\r\n8UN/9HwfeR6pC8BZ+8t93q8oPW+6HUM1GbASC2neMFjVfx2iOxsL4Xto7gti\r\np/YLvjXJcva3hYvkhAvKICLADeqKgAOS+FgfYTS8V3d36nvpvqNNtql+sutE\r\neVZoD865P2wNTNDtwsxOgFxR4Ph5NIbsfikT53zLEJ1Q/f7kjQDdRXc+GIpe\r\ngSJgZFPUaA69rL6v98v1C80W7Nc6VUDUu6PvAqJMvqtwWyRQeb8+ArohOBcQ\r\numtKG2cbImZO4MhVkWUebxvP7YJgSkoEuL0OwgVcC3Rh30MzCow3H52qKQ8N\r\nmLwvox8j3ihot5l8iIxSfE9qyY9F3u+QNTgTiUpC2rVXVlJu4xkmIw64WA8K\r\nPbY7mVnv6ySDutoQx6j9oClOkgJo6dy2Fu0=\r\n=Grgv\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-beta.5_1667236208094_0.744301466140795"},"_hasShrinkwrap":false},"3.0.0-rc.1":{"name":"@superfaceai/testing","version":"3.0.0-rc.1","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.0.0","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"^1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-rc.1","dist":{"shasum":"dd1111c3ada14477ca341e81bd16e57a80e90ecd","integrity":"sha512-Si30fQHw0zlhH7Uqo95d81XPERHteH3RAsP0zaxpliVxpBwpuTooiq+FIiHxNdrj/9qUyF3N7I1JUA68wqeuFg==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-rc.1.tgz","fileCount":122,"unpackedSize":373121,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4YCxOLeS7rb3p9Chohp06FUQjwf+2tvhQACP+PZAJwQIhAKrm/RBr7BvJ22ECbc69slyEKw3cu9QawCwQTR7DT5W+"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjkCyqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqqrRAAlQcpNINcxy21QaIjHGuRHCzryJ981nVfVVQCCJAe/Ju7fvw5\r\n/pDMq8ewjullvgVagKCGJMifPUBh1VahCP4vup7HrqoAveKVXZ9z4jpSyWBR\r\nh6wyb509YuNSEwXUOWgtTdRckq51fp2j6qEjLzjAUJP4NeG4F2wDDfqJODfG\r\npGUAfVk71vALAX7QVNinzo7FRsoFXHkpGdC9ToOF8e4ohWIInYHYaI5BaosJ\r\n+qMdcjjobXCmHyvSevhS+iCYyA38JcrHVcQ3HMYoaBPLAl+1jbPf65OjcIL2\r\nFjFG7YT694lEpfkIpIe5nM5AayGbpYGHHjh+DMXTgL0SBtbtnblvAjjyaiwD\r\n8WD03QaIVI64g1g4RLgrBW/QgYRy26TyRI+vOpmh0H4q0VOwPQNyMgkZdrEd\r\nGlpn2/WuW9Bs07N2eiWi/sG1hnQkkqSDkl8GGSkHooU7agQ93pir9D6ADPkV\r\nWyRxxOOzNAC8NgdAnq/8xYbEJXT5JT5RHe9RgszzPkKneeKuyn19MB9HnbHX\r\nwlHzN0GK6JUa6L4WNciuSPxP9RkjGB3qtJn5N0KcLAgxjkgQkaue4Cq2zuxr\r\n1wyiuK5fpoKam2nA8jkTOjscoR+fRv75BHiiyJYVTTEM+X7kLpmcwTRqrqEK\r\ntalm1NYEOk0OF6ThSPE+Z63YWOPPD/09Ktg=\r\n=vmNK\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-rc.1_1670393002296_0.6728374822219905"},"_hasShrinkwrap":false},"3.0.0-rc.2":{"name":"@superfaceai/testing","version":"3.0.0-rc.2","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.1.0","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"^1.2.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0-rc.2","dist":{"shasum":"f72471098bcf296ed631063e3627c3d15437bcf0","integrity":"sha512-u20fqa0tzwySUoA3UyHkSGqlSHNglKZsfoysgJ9fMmdSYR5Gr444pg+gaZ/OVoM6jLqZ9gq9I65P1WoLivll9g==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0-rc.2.tgz","fileCount":122,"unpackedSize":373121,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCxGioWG8+cqtio2a6GY0wc2T4PpiNu2lMwoG4G86Ym6wIhAL+QimfgyiwTjvo08cub++6V5pEw1fnr8p6cDqJ0w73r"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjkJQSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpIOw//Vw+KsOb0O5j+PToOxYWspwkRWRaLCsJw82EnO0fpDjrMj+Vn\r\nZWRwLyQBmAWBnQLKvSITBWiIne9Vn00ZKe5TIRo99rBkL1hYEnG9eQlc8lqq\r\n7rRZsU9ZKmdZAXM+lD1NgBEU99o3VPSdEKprOyV3Z8uQRf30A7NWqRjXoQJp\r\nTczZLp102hQwsj9Km1PciXrXj16ezNSBSulhiS8b9jLCmxvaTI8weaP6Qh4a\r\nIknKNuphImXeDmyiLeEu2uU1EftF7OUtLgHfz2Jf0lxqLdgDVA6JXKG03DMh\r\nnxCOXBVtbYXBIOpDnBnjyhIwA0bJRowXT7aEeWZR429CrHjChH697YxaaWlZ\r\nVml4wNtpDscdTZgJ6DrpmyrVj1wXhLsF0w/5i2APSY+w9nTaK/73cZ5ZBOEz\r\nMq2pXNrF/2A+okJ4KtQtyUumgrxDssHmCf5/bdE0XMwYBhcZPs5kp5Bmy4Ww\r\nh8zlI4wx74/VMS66MpueiUOL2ajKc+onl5/O8pFfkmt9AMp8GZM9/Mt8tTLs\r\nsc2EkV6wbYQCvxd/bl13IYtoHLrirF3GUHW8Dp/U7VZ6Fi/Rr5gnoPt2WXTt\r\nQIHonoPuWsQalyzU1agi0ObJ0UPPqZNVd02bR28L4uFbhSzn/rt9UNwIRuo+\r\nctB2rN36FaXq/BbhsI5yTq6qEK2318jOyFE=\r\n=Ryna\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0-rc.2_1670419474690_0.4877691219218645"},"_hasShrinkwrap":false},"3.0.0":{"name":"@superfaceai/testing","version":"3.0.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.1.0","@superfaceai/parser":"1.2.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.0","@superfaceai/parser":"^1.2.0"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@3.0.0","dist":{"shasum":"68a0876f1ec545530770c9cb3523884ec907eca0","integrity":"sha512-6MV/tZlGrTfVSSotHKh/sp7WF0lT4qpSXBRvaTlFvSX5aszNiWros97z+4DNh7RlJXMuYO96GJ86v/JHgZbXDA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-3.0.0.tgz","fileCount":122,"unpackedSize":373213,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDHPdBDBXVVsF7yDqn1PGnOVWQ/h9eiExQmp47EpMFmxAiEA1d8mWQrumhB5MZvDbcMteJ9Rd2ijKJfP68WuqeNvrh8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjkLfpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrZVg//adD2sXa/w4OGa6QwFsD4POPqOdTHpJhfYBvTYrCvz46JHxwb\r\nSTHnFnjCksTjgH2rJam/xpjR4E+JxhstzI+Pm4cp6jSt12P3fSV27rmjDoH3\r\n8yutKU2dfnJE+5HP7LHarqfIKbZZRMWUwa5xvYinEy8v5w+hk2Rbh4bw5Lyo\r\nzgmiJdbkfTdFtRdF3w+lfOEEW9+j+x+P6H3heuOIcG82268KtB8Mg+E6ukJN\r\nmNOmzol/Ro8koDgrqBVakweHqmQ7F5mqr1H/PrbOKahDg0Nd+ejHT47jL96V\r\nW3cZSkicZoPg64wT3Xy2PzZnLIDTllnhA6sdDJvNbozaXyGDYWjPKRm5iKx9\r\n84Tsyz75O/w/igFjfB9KVqBLPX6Zk6BfvpWDf2wrjPD+jx+fjYuBMGRY7km3\r\nFut5fEc/N17L5Ax5TWCXXw34vJYOOKEAM16QRvnEdL/Ezs2BElxA4ftt9Wff\r\nXpTPKCCC23FQ2ywCYqd48tXtEHfomDDOZySe+RDxNH5H/gAq8lOlF5XsJSRa\r\nNYfYQE/dMhFOOF7q35G7C1oGjXsnvATDyv+kgbDZbMbQ37l2fnGbk3sg4Lbf\r\nKE7dW8iKeQZqm4lP3dstycyP6qV0kKnY6CBl43CJBmZlSrtO9PQc8lJKjoHt\r\nHKNlQDOcuO2atETGOxGd5O1++S2OpTf2Jgo=\r\n=pdDW\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_3.0.0_1670428648845_0.31301864730712614"},"_hasShrinkwrap":false},"4.0.0-rc.0":{"name":"@superfaceai/testing","version":"4.0.0-rc.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^2.2.0","@superfaceai/parser":"2.0.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.2.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.2","@superfaceai/parser":"^2.0.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@4.0.0-rc.0","dist":{"shasum":"469732aca46079039eaf4815490ad94e066b70f4","integrity":"sha512-J1JkVBuKgzg05EXMtsPqidgVgKz/e2O40wovTf5xikeFvW4Mrt4bEbF8ntZlcK4lK9Vb3lY7Lf6x8oe8zGiBiQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-4.0.0-rc.0.tgz","fileCount":122,"unpackedSize":373399,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/qwlMK/BBbshpA3yuVCaX4jD4YjboxlZdqvtN9Xu7zwIgXZST4sEcS4uH3/C2mh6nS9RqiydPGqj/kvvyjLqZJoM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj0m9DACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrlqhAAnb1ZIOLDZXutGaKxRqdeP0kva+PNOoLWE9rKHz95Aw9Q4MVW\r\n52kXpT1XspAcknqg3MP6iDqd08ZlRua3I/M8vBWInD1taoT9IZF/+v8m31Ys\r\nUs5S8HCdLH3MxDGigJD2AAHO7FC9Q6ovfQ6Nq3ndnTZ6lgODazO8SNJiDXc8\r\nDTn1VzBEgNS+Ryb5UTu2Njz6A7mLz5YotHEj0pI5Uaj857GgRyLOthrmcO/j\r\nrMhj7UDLZ1g7njEF2tJm+xY7cbgWckWrWTwEI6yxVimfH+i1duQ7kXEQdPTh\r\nSyZ5libffmeSnHsskHVVCgRxDIuBPwrpHcE+mgRLJxa4+Kpdy5yYz7dzvviM\r\nMX4NoXhZesnrn9Ztaczgfx2QFdb2zS8qRwt1HD7DdHZ5HT+5GYbZ8TVla7LE\r\no2F428P64yePEUXTQYiP9boWvE2Lmn83Q0B5ktDiyG+vX1QdiUEfrTXJKUIW\r\nydhe2w+S4LlLcFJcPtDSkri/ZClvPVKsFPqaRVKMEG1PCbOTzdEAp2IW7bXS\r\n6EQNqwSu0VsQlgQYa10gyfS0PwnakS17vMkagQq/AGatwqqfBFknSNRMOefu\r\ndSkTFCrTF9Ume/FgOpX428E/aKTS4D0J25r2Za1CHuwIQziUeGU9Aw1+sfH/\r\n91/IN740EHidg2XlJwsOzJ0mJC5lODuycCk=\r\n=NmDU\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_4.0.0-rc.0_1674735427034_0.5303094626274736"},"_hasShrinkwrap":false},"4.1.0-beta.0":{"name":"@superfaceai/testing","version":"4.1.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.3.0-rc.0","@superfaceai/parser":"^2.1.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.3.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.2","@superfaceai/parser":"^2.0.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@4.1.0-beta.0","dist":{"shasum":"07fdb2e17244d225d0fafcd12c99d4a5c8ad50e8","integrity":"sha512-48YgXtkPy1zHQYSnWGGynDXeKSjvSwjmPQjLkA3vR25VjHFJ8d9PSpszy/8wziIu00dhhbAE+IS7jc3PAAVpuA==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-4.1.0-beta.0.tgz","fileCount":122,"unpackedSize":373755,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHuHIe+NAuwtKAuMtar9/r0Id9DDpvIETNnQRLmYBJWBAiEA/86j42SM0R6t7VgC4dvl3PoDOT9m6wWCVNESNbZkcE0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2tU0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoMKA//RWuo1CfyQMDlyI+DRDG0E266ohaZ5soafqh0sucOSHaCKG9c\r\nj61zmvDBJ43TIj+PJtF1y2umNizSD4CAygpcU6MbXUqaSlYMha2g26iD5Tgf\r\nc14MADxf40E/k8TeNCr8h1pr9e7XXxRtkmtoa5RtNaf9Ryn4iMRq8VCNeVqM\r\nDfD2HMZhTt2Ci2YXJrgQJJLxeTyIPGbkE3SzgDaT9/94aLTIsaCbiJiIrh+a\r\nlSQYaILJ2iEbEIkzO+x7Z13F4gN5MSrgMbRFKxK0oUPKwXnPz3ez/cJ7LSAL\r\n/y2Z2XyzbxsnfrqH1frbpnoz6EuFQbgk94S3B96m8BEToLC3lDpoQxJ6MyV9\r\ntO0bDCPXnnypdtTSYFLDqx1dNoovCuKbFeOBDQmwwKcbAy3aGxuTdM8io4Bc\r\nM0I/o/aNmFaXThDgUPw0MxPMScM8vhWsg0/TVtE3+GWRperXta2p/md2tB+K\r\nJrfNOJob148V62+ZeFWX8jRcZouoFZQMAW8Sb7w06UUt9lJXkwIhj4ECygoq\r\nqst/VYDkRWUtiiJR/ctnlnXOcX/e9wX+V7GnZ08xpL6+3Lp1vXXnj+DQMxWG\r\noP+xMBn/NnYs62mrpsNx92THnllR6aZ/rmaoiv9DHfBBTVS+O1jhiH8LQf3f\r\nrOjodC7zT/JXjmdm5tG6xasMrlrBkPXDVxk=\r\n=q3bN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_4.1.0-beta.0_1675285812329_0.6925768757511634"},"_hasShrinkwrap":false},"4.0.0-beta.0":{"name":"@superfaceai/testing","version":"4.0.0-beta.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"2.3.0-rc.1","@superfaceai/parser":"^2.1.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.3.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.3.0","@superfaceai/parser":"^2.1.0"},"readmeFilename":"README.md","readme":"# Superface Testing Library\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/superfaceai/testing/CI)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@4.0.0-beta.0","dist":{"shasum":"7dda3fc262b938c6fd66d7c418fd097116050d73","integrity":"sha512-xMeoLDNiEetJ5r+LzWh5KmtWEHEEtRT+QZ49sjU3R43o/uBuB84eYBOmUhEdKZ0I8i2cPSEl4vxoBcjgxjsYDg==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-4.0.0-beta.0.tgz","fileCount":122,"unpackedSize":373820,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCHzDo6R+F0AUNxNbZgl4AdPl8lr5iKDjpqm9IzB41NOwCIAHVJlz7BClABFmOu/rbZlSPQWOqtAye+YVWZ/HCI8Ph"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj4mQ8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqflA/7BGDDcYpB1NFePGMbvnd/zRAK6Js/wv70gJ5TrbxOMw/XLAZU\r\nC+LWagOT+iKrkWXnkVoNsB7Dc85HX7UEK0Lqvze7tLI1Ve/fbREDQHGM5ayt\r\ndWnHf8JMCIPmmVdltFz/MAgEuhX/waMD/Q3I+k/AZPcDfZdosqzdX3gR9O9j\r\niJqFKEN3J1mjXmUs2xPKXw1bTjxGn6STfvpP6Apsq27HMFNLCKwrB/nZ54/i\r\n/wPskTvIEDN2WB+q4PPcNfxzX0/yNK8r5VEN4hxkf2P2OlCFPmIP5FoP38Wk\r\nv9MaG0VKnmnl/WXsgRD9uXf0ivfPQVWVinYtUmg2vBOtdRaw4CgWROfC9HlA\r\nS+GERXVpg5p0qxG8ieTF63Ndzdz2X5xplTpxh3oSKwDuufgKBGzffQyk2+il\r\nqZaN7K3CrSc2rS8H5lNnc6e4d5TmOZRKdBecWS12WEJ5j/6fmAysvNM/GTTT\r\nW/uAjjoa1A0bikai3XxJcmfGJ9SOtsmwsBMQqYblkGbaZi9jNXytrq38au3i\r\nAvG5+om/Dpr0g8YmBtLsTN5TLuF8AEtNHz3mXTEaCCd3c3MPvjC8NTlVwRWV\r\nw/ZwA5uJVEqMeKbC1i2T6CwudPCd4r2on6vPZu6LgEO+dq5kLrrLwc0hYvH2\r\ncMtQ2G83lmC46pFamkZk140t6VrMe8tj5TE=\r\n=n+Ot\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_4.0.0-beta.0_1675781180588_0.9942026034142462"},"_hasShrinkwrap":false},"4.0.0":{"name":"@superfaceai/testing","version":"4.0.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^2.3.0","@superfaceai/parser":"^2.1.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.3.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.3.0","@superfaceai/parser":"^2.1.0"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@4.0.0","dist":{"shasum":"ed5e5fc8e8089d4e142c635bed5dd6e91e6d9703","integrity":"sha512-ZOgdnekdggIwNuJS1sd80o/XYD1/RvBnBG4isgPAWaiwOuWdIu+04eIdHSJmNiVD6i8Z6HGH+ItBgfaJXhhhIQ==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-4.0.0.tgz","fileCount":122,"unpackedSize":373843,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHBeE6MxIuOdRxKvjyIOXabliEwdDNB6grpJJpSyOaxTAiEA0j1GNE1nkb3vZ0HxDThJdyfuR5EokJbj+q243I+wB1s="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj43r3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoKBw//evK4B/TDpXa6aOBdOdfx5lPIJsJuRfH2EPiwM9Ghvp1yT8c6\r\n0vae/Yogh11NJBUpHgTsUMtgulIH9VdpIoQNOIcBO347Fx2vGyTNKq/HU3SA\r\nxLVV6YmZeudZwrFzTemeF4CEyqSr1RpbpL0+HJeLpg/6NHO/hx0l+a9tYT1A\r\n49cn0nMlZWlyGh1iuTmiMUnUx7GzFpChEDQ5bSwMvDY3QwxD69ZbXMcYdBYn\r\ncmSzfiezC45kScHu/cceVFMTcw0ZpxAeiaOxwN5dqTanW0czSZwuDYkZX8EF\r\nQBKtmN8IWNP5HURi26kM/ZUvXLdcywOhKlQZxfU42mHyJo6heCDt4ulfoikH\r\n5jzyQEw+seiP8UEYoBgnQ8jkfxh201tn0SLFR/uRNrQbeaBSlQlH/zwBLXQo\r\nax4S6HlcYSK9DjkWn+cAX54FX3Fj4ApvAD6BZCzxMI83updLn5wM0IRa1a/R\r\n1qHDmuMzxUEUMrPNemsmsto1YmqQT1yG0hJaEUcc/hpVUy4nuncff8Cr+/8U\r\neEnlUbcVaN0F+c6YzrnAlVoxPCCTEKZwYHLFmv/mQc0vSP4BgIJosyPNq7If\r\nDUa06d447/pNfM1nnecJz7Ecem6XsbblGTgAWQM2rYSLdlmU0tee1wbxXyIt\r\n1qoNcK0IhfrLK52cD0VYj6gExuxb9fyV49s=\r\n=2wah\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_4.0.0_1675852535470_0.6620535326029449"},"_hasShrinkwrap":false},"5.0.0":{"name":"@superfaceai/testing","version":"5.0.0","description":"Testing library for Superface capabilities.","main":"dist/index.js","source":"src/index.ts","types":"dist/index.d.ts","author":{"name":"Superface Team"},"private":false,"scripts":{"build":"tsc -p tsconfig.release.json --outDir dist","watch":"yarn build --watch","clean":"rimraf dist/","prebuild":"yarn clean","test":"jest","lint":"eslint src/","lint:fix":"yarn lint --fix","format":"prettier -c src/","format:fix":"prettier --write src/","prepush":"yarn build && yarn test && yarn lint && yarn format"},"devDependencies":{"@superfaceai/one-sdk":"^2.4.0","@superfaceai/parser":"^2.1.0","@types/debug":"^4.1.7","@types/jest":"^27.0.1","@types/rimraf":"^3.0.2","@typescript-eslint/eslint-plugin":"^4.29.2","@typescript-eslint/parser":"^4.29.2","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.24.0","eslint-plugin-jest":"^24.4.0","eslint-plugin-simple-import-sort":"^7.0.0","jest":"^27.0.6","prettier":"^2.3.2","rimraf":"^3.0.2","ts-jest":"^27.0.5","typescript":"^4.5.5"},"dependencies":{"@superfaceai/ast":"^1.3.0","ajv":"^8.11.0","debug":"^4.3.2","genson-js":"^0.0.8","http-encoding":"^1.5.1","nock":"^13.1.3"},"peerDependencies":{"@superfaceai/one-sdk":"^2.4.0","@superfaceai/parser":"^2.1.0"},"licenseText":"MIT License\n\nCopyright (c) 2021 Superface\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","license":"MIT","_id":"@superfaceai/testing@5.0.0","dist":{"shasum":"aadd9f08843eb3bc71371fde74608c325c59329f","integrity":"sha512-uLDDirvnVKKi/eM70TUBjfGp/xQ4Kk+nAAGNjfQ82Q31bJHoglHvzVjXLp3xC88VkPULzOeFPiRu3etcSJAlKw==","tarball":"https://registry.npmjs.org/@superfaceai/testing/-/testing-5.0.0.tgz","fileCount":125,"unpackedSize":375593,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIfom8zgRRtK+kBYoBzcspqWBu5qhFsYUvPYh2MB42LAiEApTcYmSmTmOCBQwr15QwoWd8Xubtd/7A54hk2S8aXHyM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/HaVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqNVg/+O+FcWXgMY4yEZ2pwzuDEZdTLCa9ZlzUj2DRrbr2Xlj9GNilE\r\nISNJQxKqSdCzRMxnO10NjQedQW9MXaG3nD8TArv+vc1+zzkjXsOqN+dNlRUh\r\nw5Do28GwLP5ONK1+KtN4UQ39p9ILbmaMdPwsLwTUcRK7FKvsQYhEDUTJORWn\r\nue6vEQbcf4KheLl/ydRWDtb0DKGJ6YQVVosixtpqgK8zHDilFe0wnWmWzU5Y\r\nLPqg7xqMp92QQTAydOAddFqiI2IE4f2NmFaZSgqzybT9qX/3jcZ7O5dziNDM\r\npDC3cMCe6wXHnK2GjfYolsxxxUdYsqy7l86j2c7Z1CkGCZhjF5EKrMENWgAo\r\nLTPjGncVw1mUcD/ZuxBRTcOuDHX+xdbSa8vtGuMV5y4B5WsaXc3ihIQ/p2ed\r\ncYx372vdPj2amqc5SnFLxI4s9TJenMD+sk8Kcrkbn6ZRN6a0yFN1QHDobVue\r\nH/Qr24O16eJ1Clqfx/9h6nHmR52f5vQF7sRX701xmITQF/u05gXLQ4LXvP5S\r\ndJMz9BDW9cKfllYioo5C7QADBSBxLYaQwmciMZznuBuKcBVBcAyoC04G8mqA\r\nVRpg0njVVzniIE3IWI+nOB9FArxa+cP29Ws6gZ/GW+pTBOzEGZU0NYihDX/+\r\n+tSTCQ0sZygTy5PT4G21j5kL1Hog6vs8OGg=\r\n=IJlp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"superface-bot","email":"hello@superface.ai"},"directories":{},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/testing_5.0.0_1677489813746_0.7958584405648339"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-05T13:43:32.182Z","1.0.0":"2021-11-05T13:43:32.452Z","modified":"2023-02-27T09:23:34.018Z","1.0.1-rc.0":"2021-11-22T13:48:15.099Z","2.0.0-rc.0":"2021-12-28T12:30:57.894Z","2.0.0":"2022-01-17T09:58:06.243Z","2.0.1-beta.0":"2022-02-14T11:49:41.394Z","2.0.1":"2022-02-14T12:13:23.960Z","2.0.2-beta.0":"2022-02-15T12:08:51.784Z","2.0.2-beta.1":"2022-02-15T13:29:55.320Z","2.0.3-rc.0":"2022-02-15T14:41:03.316Z","2.0.4-beta.0":"2022-02-15T18:54:23.172Z","2.0.3":"2022-02-15T19:04:27.088Z","3.0.0-beta.0":"2022-06-07T12:42:02.342Z","3.1.0-beta.0":"2022-07-21T09:33:24.462Z","3.2.0-beta.0":"2022-07-26T15:19:22.036Z","2.1.0-beta.0":"2022-08-18T10:05:31.660Z","2.1.0-beta.1":"2022-08-18T11:42:46.229Z","2.1.0-beta.2":"2022-08-24T10:36:44.461Z","3.0.0-beta.1":"2022-08-24T18:28:14.023Z","3.0.0-beta.2":"2022-08-29T11:32:38.470Z","3.0.0-beta.3":"2022-09-07T08:39:57.668Z","3.0.0-beta.4":"2022-09-07T09:36:36.598Z","3.0.0-rc.0":"2022-09-15T11:55:42.504Z","3.0.0-beta.5":"2022-10-31T17:10:08.274Z","3.0.0-rc.1":"2022-12-07T06:03:22.509Z","3.0.0-rc.2":"2022-12-07T13:24:34.892Z","3.0.0":"2022-12-07T15:57:29.023Z","4.0.0-rc.0":"2023-01-26T12:17:07.206Z","4.1.0-beta.0":"2023-02-01T21:10:12.569Z","4.0.0-beta.0":"2023-02-07T14:46:20.738Z","4.0.0":"2023-02-08T10:35:35.707Z","5.0.0":"2023-02-27T09:23:33.895Z"},"maintainers":[{"name":"zdne","email":"z@goodapi.co"},{"name":"freaz","email":"mail@ondrejmusil.cz"},{"name":"superface-bot","email":"hello@superface.ai"}],"description":"Testing library for Superface capabilities.","author":{"name":"Superface Team"},"license":"MIT","readme":"# Superface Testing Library\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/superfaceai/testing/main.yml)](https://github.com/superfaceai/testing/actions/workflows/main.yml)\n![NPM](https://img.shields.io/npm/v/@superfaceai/testing)\n[![NPM](https://img.shields.io/npm/l/@superfaceai/testing)](LICENSE)\n![TypeScript](https://img.shields.io/badge/%3C%2F%3E-Typescript-blue)\n\n<img src=\"https://github.com/superfaceai/testing/blob/main/docs/LogoGreen.png\" alt=\"superface logo\" width=\"150\" height=\"150\">\n\nThis library enables easy testing of local Superface capabilities with `SuperfaceTest` class. It uses these capabilities either with live HTTP traffic or with recorded traffic (More about recording HTTP traffic in section [recording](#recording)).\n\n## Table of Contents\n\n- [Background](#background)\n- [Install](#install)\n- [Usage](#usage)\n- [Recording traffic](#recording)\n- [Support](#support)\n- [Maintainers](#maintainers)\n- [Contributing](#contributing)\n- [Licensing](#licensing)\n- [License](#license)\n\n## Background\n\nSuperface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.\n\nThrough its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.\n\nSuperface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.\n\nMotivation behind Superface is nicely described in this [video](https://www.youtube.com/watch?v=BCvq3NXFb94) from APIdays conference.\n\nYou can get more information at https://superface.ai and https://docs.superface.ai/.\n\n## Install\n\nTo install the package, run in the project directory:\n\n```\n# npm users\nnpm install -D @superfaceai/testing\n# yarn users\nyarn add -D @superfaceai/testing\n```\n\n## Usage\n\nTo test Superface capabilities, initialize a new `SuperfaceTest` instance and call its method `run()` with test configuration and input specific for your test run. Test configuration should contain `profile`, `provider` and `useCase`. You can enter them either in string format (as ids of corresponding components) or as instances of corresponding components (more about them in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#using-the-onesdk) or in [Comlink reference](https://superface.ai/docs/comlink)).\n\n### Initializing SuperfaceTest instance\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n```\n\n**without any arguments:**\n\n```typescript\nconst superface = new SuperfaceTest();\n```\n\n**with superface configuration:**\n\n```typescript\nconst profile = await client.getProfile('profile');\nconst provider = await client.getProvider('provider');\nconst useCase = await profile.getUseCase('useCase');\n\nconst superface = new SuperfaceTest({\n  profile,\n  provider,\n  useCase,\n});\n```\n\nGiven test configuration is stored in class and used later in `run()` method.\n\n**with superface and nock configuration:**\n\n```typescript\nconst superface = new SuperfaceTest(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n  },\n  {\n    path: 'nock-recordings',\n    fixture: 'my-recording',\n    enableReqheadersRecording: true,\n    testInstance: expect,\n  }\n);\n```\n\nSince it uses `nock` to record HTTP traffic during perform, second parameter in SuperfaceTest constructor is nock configuration containing `path` and `fixture` to configure location of recordings, property `enableReqheadersRecording` to enable/disable recording of request headers (This is turned off by default) and also property `testInstance` to enable testing library accessing current test names to generate unique hashes for recordings (currently supported only Jest and Mocha).\n\n### Running\n\nTo test your capabilities, use method `run()`, which encapsulates `nock` recording and `BoundProfileProvider` perform. It expects test configuration (similar to initializing `SuperfaceTest` class) and input. You don't need to specify `profile`, `provider` or `useCase` if you already specified them when initializing `SuperfaceTest` class.\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\nconst superface = new SuperfaceTest({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n});\n\nsuperface.run({\n  input: {\n    some: 'input',\n  },\n});\n```\n\nExample with jest:\n\n```typescript\nimport { SuperfaceTest } from '@superfaceai/testing';\n\ndescribe('test', () => {\n  let superface: SuperfaceTest;\n\n  beforeAll(() => {\n    superface = new SuperfaceTest({\n      profile: 'profile',\n      provider: 'provider',\n      useCase: 'useCase',\n    });\n  });\n\n  it('performs corretly', async () => {\n    await expect(\n      superface.run({\n        input: {\n          some: 'input',\n        },\n      })\n    ).resolves.toMatchSnapshot();\n  });\n});\n```\n\nMethod `run()` initializes `BoundProfileProvider` class, runs perform for given usecase and returns **result** or **error** value from perform (More about perform in [One-SDK docs](https://github.com/superfaceai/one-sdk-js#performing-the-use-case)). Since testing library don't use `SuperfaceClient` anymore, it is **limited to local use only**.\n\n[OneSDK 2.0](https://github.com/superfaceai/one-sdk-js/releases/tag/v2.0.0) does not contain parser anymore, so it looks for compiled files `.ast.json` next to original ones. To support this, parser was added to testing library and can be used to parse files when no AST is found.\n\nMethod `run` also have second parameter, containing parameters to setup processing of recordings described bellow in [Recording](#recording).\nOnly one parameter from this group processes result of method `run` and that is `fullError`. It enables method `run` to return full error from OneSDK instead of string.\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    fullError: true,\n  }\n);\n```\n\nYou can then use this return value to test your capabilities (We recommend you to use jest [snapshot testing](https://jestjs.io/docs/snapshot-testing) as seen in example above).\n\n### Recording\n\nMethod `run()` also records HTTP traffic as we mentioned above and saves recorded traffic to json file. Before perform, library will decide to record HTTP traffic based on environmental variable `SUPERFACE_LIVE_API` and current test configuration.\n\nVariable `SUPERFACE_LIVE_API` specifies configuration which needs to be matched to record HTTP traffic.\n\nIts format is: `<profile>:<provider>:<UseCase>` where each component is optional and separated by `:`. It can start or/and end with wildcard `*`.\n\nIt will be then compared to current test configuration and start recording if they match.\n\nFor example in method `run()` bellow, to record HTTP traffic, `SUPERFACE_LIVE_API` has to be one of following:\n\n- `profile:provider:useCase`\n- `*` or `*:*:*`\n- `*:*:useCase`\n- `*:provider`\n\n```typescript\nsuperface.run({\n  profile: 'profile',\n  provider: 'provider',\n  useCase: 'useCase',\n  input: {\n    some: 'input',\n  },\n});\n```\n\nTesting library process recordings to hide sensitive information that might get recorded based on security schemes and integration parameters from provider.json and super.json. To turn this off, specify boolean `processRecordings` in second parameter for method `run()`:\n\n```typescript\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n  }\n);\n```\n\nTo hide sensitive information that are passed in method `run()` as `input`, you can use parameter `hideInput` to point to primitive values which will get replaced in recording fixture.\n\n```typescript\nconst pass = 'secret';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      auth: {\n        username: 'user',\n        password: pass,\n      },\n    },\n  },\n  {\n    // value found have to be one of following: string, number or boolean\n    hideInput: ['auth.value', 'auth.password'],\n  }\n);\n```\n\nYou can also enter your own processing functions along side `processRecordings` parameter. Both have same function signature and are called either before load or before save of recordings (see [this sequence diagram](./docs/sequence_diagram.png))\n\n```typescript\nimport { RecordingDefinitions, SuperfaceTest } from '@superfaceai/testing';\n\nconst beforeRecordingLoad = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace('PLACEHOLDER', process.env.YOUR_SECRET);\n  });\n};\n\nconst beforeRecordingSave = (definitions: RecordingDefinitions) => {\n  definitions.forEach(def => {\n    def.path = def.path.replace(process.env.YOUR_SECRET, 'PLACEHOLDER');\n  });\n};\n\nconst superface = new SuperfaceTest();\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    processRecordings: false,\n    beforeRecordingSave,\n    beforeRecordingLoad,\n  }\n);\n```\n\nIf you want to differentiate between runs that are used for preparation or teardown of test environment in recordings, you can use parameter `recordingsType` and recordings for that run will be grouped in recordings file as `prepare-profile/provider/useCase` or `teardown-profile/provider/useCase`:\n\n```typescript\nimport { RecordingsType } from '@superfaceai/testing';\n\nsuperface.run(\n  {\n    profile: 'profile',\n    provider: 'provider',\n    useCase: 'useCase',\n    input: {\n      some: 'input',\n    },\n  },\n  {\n    recordingsType: RecordingsType.PREPARE,\n  }\n);\n```\n\n## Continuous testing\n\nTesting library supports continuous testing with live provider's traffic. This means that you can run testing library in record mode without worrying that old recording of traffic gets rewritten. Testing library compares old recording with new one and determines changes. If it find changes, it will save new traffic next to old one with suffix `-new`.\n\nThis recording represents new traffic and you can test your capabilities with it. First time it records new traffic, it also uses it for map and therefore you can see if map works with it, but we can also setup environment variable `USE_NEW_TRAFFIC=true` to mock new traffic instead of old one when not in record mode (it looks for recording with suffix `-new` next to old one).\n\nWhen you think the new recording is safe to use for testing, you can set it up as default with env variable `UPDATE_TRAFFIC=true`.\n\n## Reporting\n\nTo report found changes in traffic, you can implement your own function for reporting and pass it to `SuperfaceTest.report()`. It's signiture should be:\n\n```typescript\ntype TestReport = {\n  impact: MatchImpact;\n  profileId: string;\n  providerName: string;\n  useCaseName: string;\n  recordingPath: string;\n  input: NonPrimitive;\n  result: TestingReturn;\n  errors: ErrorCollection<string>;\n}[];\n\ntype AlertFunction = (report: TestReport) => unknown | Promise<unknown>;\n```\n\nTo disable collecting and also reporting these information, you can setup environment variable `DISABLE_PROVIDER_CHANGES_COVERAGE=true`.\n\n## Debug\n\nYou can use enviroment variable `DEBUG` to enable logging throughout testing process.\n\n- `DEBUG=\"superface:testing*\"` will enable all logging\n- `DEBUG=\"superface:testing\"` will enable logging of:\n  - perform results\n  - start and end of recording/mocking HTTP traffic\n  - start of `beforeRecordingLoad` and `beforeRecordingSave` functions\n- `DEBUG=superface:testing:setup*` will enable logging of:\n  - setup of recording paths and superface components (profile, provider, usecase)\n  - setup of super.json and local map\n- `DEBUG=superface:testing:hash*` will enable logging of hashing recordings\n- `DEBUG=\"superface:testing:recordings\"` will enable logging of processing sensitive information in recordings\n- `DEBUG=\"superface:testing:recordings*\"` or `DEBUG=\"superface:testing:recordings:sensitive\"` will also enable logging of replacing actual credentials\n- `DEBUG=superface:testing:matching*` enables logging of matching recordings\n- `DEBUG=superface:testing:reporter*` enables logging of reporting\n\nYou can encounter `NetworkError` or `SdkExecutionError` during testing with mocked traffic, it usually means that request didn’t get through. If nock (used for loading mocked traffic) can’t match recording, request is denied. You can debug nock matching of recordings with `DEBUG=nock*` to see what went wrong.\n\n## Known Limitations\n\n### Multiple matching requests for the same use case\n\nRecordings make it possible to run tests without calling the live API. This works by trying to match a request to the requests in the existing recordings. If a match is found, the recorded response is returned. However, since the testing client saves recording for each test run in a single file, it means multiple matching requests for the same use-case and input will overwrite each other.\n\nTo solve this, you can enter test instance (`expect` from jest) or specify custom hash phrase to differentiate between runs.\nAlso a workaround is to use different inputs for each each test.\n\n## Support\n\nIf you need any additional support, have any questions or you just want to talk you can do that through our [support page](https://superface.ai/support).\n\n## Maintainers\n\n- [@Martin Albert](https://github.com/martinalbert)\n\n## Contributing\n\n**Please open an issue first if you want to make larger changes**\n\nFeel free to contribute! Please follow the [Contribution Guide](CONTRIBUTION_GUIDE.md).\n\n## Licensing\n\nLicenses of `node_modules` are checked during push CI/CD for every commit. Only the following licenses are allowed:\n\n- 0BDS\n- MIT\n- Apache-2.0\n- ISC\n- BSD-3-Clause\n- BSD-2-Clause\n- CC-BY-4.0\n- CC-BY-3.0;BSD\n- CC0-1.0\n- Unlicense\n\n## License\n\nThe Superface Testing Library is licensed under the [MIT](LICENSE).\n© 2021 Superface\n","readmeFilename":"README.md"}