{"id":13836150,"url":"https://github.com/nbalduzzi/fastify-knexjs-mock","last_synced_at":"2025-04-25T08:31:27.339Z","repository":{"id":33001727,"uuid":"112838578","full_name":"nbalduzzi/fastify-knexjs-mock","owner":"nbalduzzi","description":"Fastify KnexJS Mock","archived":false,"fork":false,"pushed_at":"2023-01-23T07:01:52.000Z","size":467,"stargazers_count":5,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T09:03:47.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nbalduzzi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-02T11:59:26.000Z","updated_at":"2021-09-22T12:25:59.000Z","dependencies_parsed_at":"2023-02-12T21:00:39.812Z","dependency_job_id":null,"html_url":"https://github.com/nbalduzzi/fastify-knexjs-mock","commit_stats":null,"previous_names":["chapuletta/fastify-knexjs-mock"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbalduzzi%2Ffastify-knexjs-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbalduzzi%2Ffastify-knexjs-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbalduzzi%2Ffastify-knexjs-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbalduzzi%2Ffastify-knexjs-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbalduzzi","download_url":"https://codeload.github.com/nbalduzzi/fastify-knexjs-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250782078,"owners_count":21486385,"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":[],"created_at":"2024-08-04T15:00:36.887Z","updated_at":"2025-04-25T08:31:27.073Z","avatar_url":"https://github.com/nbalduzzi.png","language":"JavaScript","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"readme":"# Fastify KnexJS Mock Plugin\n\n![Test](https://github.com/nbalduzzi/fastify-knexjs-mock/workflows/Test/badge.svg)\n![Semantic Release](https://github.com/nbalduzzi/fastify-knexjs-mock/workflows/Semantic%20Release/badge.svg)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n[![NPM](https://nodei.co/npm/fastify-knexjs-mock.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/fastify-knexjs-mock/)\n\n## Installation\n\n```bash\nnpm install fastify-knexjs-mock --save\n```\n\n## Usage\n\n```bash\nfastify.register(require('fastify-knexjs-mock'), options, err =\u003e console.error(err))\n\nfastify.get('/', (request, reply) =\u003e {\n  console.log(fastify.knex) // Knex DB instance\n  console.log(fastify.tracker) // Knex DB Mocked tracker\n})\n```\n\n## Options\n\nKnexJS Mock DB configuration JSON object.\n\n\u003chttps://github.com/colonyamerican/mock-knex\u003e\n\n## Test example\n\n```javascript\nconst { test } = require('tap')\nconst { fastify } = require('./app')\n\nfastify.ready(() =\u003e {\n  fastify.tracker.install()\n\n  test('GET 200 `/users` route', async t =\u003e {\n    t.plan(2)\n\n    fastify.tracker.on('query', (query) =\u003e query.response([{\n      id: 1,\n      name: 'Test',\n      lastname: 'Test',\n      email: 'test@example.com'\n    }]))\n\n    try {\n      const { statusCode, payload } = await fastify.inject({\n        method: 'GET',\n        url: '/users'\n      })\n\n      t.equal(statusCode, 200)\n      t.same(JSON.parse(payload)[0].email, 'test@example.com')\n    } catch (err) {\n      t.error(err)\n    } finally {\n      fastify.close(() =\u003e t.end())\n    }\n  })\n})\n```\n\n## Author\n\n[Nicolás Balduzzi](nico.balduzzi@gmail.com)\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbalduzzi%2Ffastify-knexjs-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbalduzzi%2Ffastify-knexjs-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbalduzzi%2Ffastify-knexjs-mock/lists"}