{"id":14967447,"url":"https://github.com/unboundedsystems/mocha-nock","last_synced_at":"2025-10-01T05:30:47.895Z","repository":{"id":33786525,"uuid":"162233880","full_name":"unboundedsystems/mocha-nock","owner":"unboundedsystems","description":"Easy recording and playback of HTTP(S) for Mocha.js using Nock.","archived":false,"fork":true,"pushed_at":"2024-05-14T08:17:26.000Z","size":246,"stargazers_count":3,"open_issues_count":10,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-14T09:34:15.720Z","etag":null,"topics":["http","https","javascript","mocha","mochajs","mock","mocks","nock","nodejs","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"poetic-labs/nock-vcr-recorder-mocha","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unboundedsystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-18T05:17:04.000Z","updated_at":"2024-05-14T09:34:15.721Z","dependencies_parsed_at":null,"dependency_job_id":"b9235098-d388-4cc4-96a8-6512b87da987","html_url":"https://github.com/unboundedsystems/mocha-nock","commit_stats":{"total_commits":136,"total_committers":5,"mean_commits":27.2,"dds":0.4338235294117647,"last_synced_commit":"1a29c22826ade45dedcbcf09bf6e294cecc7b70b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unboundedsystems%2Fmocha-nock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unboundedsystems%2Fmocha-nock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unboundedsystems%2Fmocha-nock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unboundedsystems%2Fmocha-nock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unboundedsystems","download_url":"https://codeload.github.com/unboundedsystems/mocha-nock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234631294,"owners_count":18863299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","https","javascript","mocha","mochajs","mock","mocks","nock","nodejs","testing"],"created_at":"2024-09-24T13:38:04.461Z","updated_at":"2025-10-01T05:30:47.589Z","avatar_url":"https://github.com/unboundedsystems.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm](https://img.shields.io/npm/v/mocha-nock)\n[![Build Status](https://travis-ci.com/unboundedsystems/mocha-nock.svg?branch=master)](https://travis-ci.com/unboundedsystems/mocha-nock)\n![Dependencies](https://david-dm.org/unboundedsystems/mocha-nock.svg)\n\n# Mocha Nock\n\nA library that makes saving fixtures with\n[nock](https://github.com/pgte/nock) and\n[mocha](http://mochajs.org/) easy. Just\nuse `describeFixture` instead of `describe` and it will record outbound requests\nusing nock into `test/fixtures` and read from them the next time you run the\ntests.\n\n## Install\n\n```bash\nnpm install --save-dev mocha-nock\n```\n\n## Usage\n\nUse `describeFixture` instead of `describe` and it will use nock to record all\nrequests.\n\nThe first time this test executes, it will save the HTTP request \u0026 response into your `test/fixtures` directory.\nThen on subsequent tests, it will return the saved data and not use the network.\n\n```js\nconst describeFixture = require('mocha-nock');\nconst request         = require('request-promise-native');\n\ndescribeFixture('normal test', () =\u003e {\n  it('works', async () =\u003e {\n    const response = await request('http://localhost:4000/users');\n  });\n\n  describe('some other test', () =\u003e {\n    // You can use mocha how you normally would to group tests\n  });\n});\n```\n\nIt also supports `.skip` and `.only`, like mocha does.\n```js\ndescribeFixture.skip('skipped test', () =\u003e {\n  // Anything in here will be skipped\n});\n\ndescribeFixture.only('only test', () =\u003e {\n  // This will be the only test run\n});\n```\n\n### Usage with test specific options\n```js\n// This test will not record the request to localhost:4000.\n// For anything it does record, it will also record the reqheaders.\nconst opts = {\n  excludeScope: 'localhost:4000',\n  recorder: {\n    enable_reqheaders_recording: true\n  }\n};\n\ndescribeFixture('normal test', opts, () =\u003e {\n  it('works', async () =\u003e {\n    const resp1 = await request('http://localhost:4000/users');\n    const resp2 = await request('https://google.com/');\n  });\n});\n```\n\n## Configuration\n\nDefaults:\n\n```js\n{\n  // Don't record any requests to this scope\n  // It can be an array or string\n  excludeScope: ['localhost', '127.0.0.1', '0.0.0.0'],\n\n  // Re-record and overwrite your current fixtures\n  overwrite: false,\n\n  // Record fixtures when test fails\n  recordOnFailure: false,\n\n  // These options are passed to the nock recorder that runs behind the scenes\n  // to capture requests\n  recorder: {\n    output_objects:  true,\n    dont_print:      true\n  }\n}\n```\n\nTo overide these you can call `describeFixture.setDefaults` with an object to\noverride them for ALL tests. It must be called before any `describeFixture()` is\ncalled to work properly. The best place is in a test helper file.\n\nYou also are able to pass in test specific options as the last parameter to\n`describeFixture()`. See the [Usage](#usage) section above for an example.\n\n\n## Authors\n\nOriginally based off of an older version of [nock-vcr-recorder](https://github.com/poetic-labs/nock-vcr-recorder-mocha)\nby Jake Craige.\n\n* [Mark Terrel](https://twitter.com/MarkTerrel)\n* [Jake Craige](http://twitter.com/jakecraige)\n\n\n## Legal\n\n\u0026copy; 2018-2019 [Unbounded Systems, LLC](https://unbounded.systems)\n\n\u0026copy; 2014 [Poetic Systems, Inc.](http://poeticsystems.com)\n\n[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funboundedsystems%2Fmocha-nock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funboundedsystems%2Fmocha-nock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funboundedsystems%2Fmocha-nock/lists"}