{"_id":"@clarkieryan/typeorm-fixtures","_rev":"1-43cd66cad4a28ed0627cc316f58a5545","name":"@clarkieryan/typeorm-fixtures","dist-tags":{"latest":"0.8.5"},"versions":{"0.8.5":{"name":"@clarkieryan/typeorm-fixtures","version":"0.8.5","description":"Fixtures helper for typeorm","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rm -rf dist && tsc","new:version":"npm version patch && npm publish && git push origin master && git push --tags","test":"npm run build","prepublish":"npm run build"},"repository":{"type":"git","url":"git+ssh://git@github.com/altiore/typeorm-fixtures.git"},"keywords":["typeorm","fixtures","fixture","helper"],"author":{"name":"Razzwan","email":"razvanlomov@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/altiore/typeorm-fixtures/issues"},"homepage":"https://github.com/altiore/typeorm-fixtures#readme","devDependencies":{"@types/lodash":"^4.14.116","husky":"^1.0.0-rc.14","lint-staged":"^7.2.2","lodash":"^4.17.11","prettier":"1.14.2","typeorm":"^0.2.7","typescript":"^3.0.3"},"peerDependencies":{"typeorm":"^0.2.7","lodash":"^4.17.11"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"src/**/*.ts":["prettier --write --print-width 120 --trailing-comma all --single-quote --parser typescript --arrow-parens always","git add"],"*.{js,json,md}":["prettier --write","git add"]},"gitHead":"5a79ee10803c26882bb967b215804945246ee919","_id":"@clarkieryan/typeorm-fixtures@0.8.5","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"clarkieryan","email":"clarkie.ryan@gmail.com"},"dist":{"integrity":"sha512-I3vpZLRXPJ+zr5HmCURHpUKeJm9fjyTfIgHIPO/4NE+0Y7jsOAmCfhxvwes/9O7I2ErzLEtQxeFwCQS+Ka6qkw==","shasum":"0329852d9acf0cd72ae41fce0dd6476dc66bd6e9","tarball":"https://registry.npmjs.org/@clarkieryan/typeorm-fixtures/-/typeorm-fixtures-0.8.5.tgz","fileCount":13,"unpackedSize":20572,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb9fANCRA9TVsSAnZWagAAM1cP+wbUXlgedpdDdnnmLZ+T\n/zfHEMkglwVUYejbQt3f6j7PfmVRCbTtMawczoCljHJIPkE8KmJgw3KfIIQc\ny1u9T3ygDJVgauEg2nlDw1fQxvJfZMMulhUlx0WbXgFwIjBzGAmT8VTWxtIU\nQlpioViIkh9NnQAml2fcJouvCgpTpOCMgQ2JNgKTIwuAvCmsqAxsCdPdNlwM\nI202XELTyl0E0wAoVd5uN0O8h61mu8Ejkzgyyqr7IVJrCkJWfbY6amppFlEC\nzrRQJgYCC9yWamkuk+hh0l5PheWOYXV6PwbG15r+37B05Nzdzez00G0ka0FQ\ncGsywlZqYNqryhpnaGeptKt+DV43Qmp9xoYl7KnGkUNCGCB6Sfoo6nkAfqET\no9RFmsRacU1WBbfeAHd4K0Sh0zyPMpb3p8pb7ib91XKNBEpNan4O46S3b3HW\nnEZHSVQUZcLzezDrg4ZW9f8zstiTg1OmJoXqrzfIPSBFSRdCGzShYuoBodUU\n08dgCkggeR7i6W3MJkAh41J4gNMeOTdK+z6j+m9lGOOFGylCUqnvxs3T6smL\nuctzUvZhI6ohpSx4ZJgyDj7cOJ5eV/A1MFtX2P1bvLqbXjf3U5//M/2XDnNl\ncL46/OEyFHXMo5XcRcOLCOYIRGHWb6vV1ynccrKCo7ki4f8bsL8iLJRMf7hI\nQVsL\r\n=m3If\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGfcl1d2o52qFXxWOpQc0S4dQMPktITkTYt8jEIK1ogOAiA0PWWeKgLS8Bjx9D7IW3h8YQ0uZ0mvAzI4K4z1nIO5QA=="}]},"maintainers":[{"name":"clarkieryan","email":"clarkie.ryan@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typeorm-fixtures_0.8.5_1542844429187_0.12106446629269363"},"_hasShrinkwrap":false}},"time":{"created":"2018-11-21T23:53:49.018Z","0.8.5":"2018-11-21T23:53:49.353Z","modified":"2022-04-04T23:13:06.015Z"},"maintainers":[{"name":"clarkieryan","email":"clarkie.ryan@gmail.com"}],"description":"Fixtures helper for typeorm","homepage":"https://github.com/altiore/typeorm-fixtures#readme","keywords":["typeorm","fixtures","fixture","helper"],"repository":{"type":"git","url":"git+ssh://git@github.com/altiore/typeorm-fixtures.git"},"author":{"name":"Razzwan","email":"razvanlomov@gmail.com"},"bugs":{"url":"https://github.com/altiore/typeorm-fixtures/issues"},"license":"MIT","readme":"<div align=\"center\">\n  <a href=\"http://typeorm.io/\">\n    <img src=\"https://github.com/typeorm/typeorm/raw/master/resources/logo_big.png\" width=\"246\" height=\"114\">\n  </a>\n  <br>\n  <br>\n  <a href=\"https://badge.fury.io/js/typeorm-fixtures\">\n    <img src=\"https://badge.fury.io/js/typeorm-fixtures.svg\" alt=\"npm version\" height=\"18\">\n  </a>\n  <br>\n  <br>\n</div>\n\n## Why we need it?\n\nQuite often we have to load data into a database before running tests.\nThis library helps to solve this problem effortlessly.\n\n## Usage example:\n\n#### 1. Create fixture creators (only once per project)\n\n```typescript\nimport { fixtureCreator, many, one } from \"typeorm-fixtures\";\n\nimport { Role } from \"../..\"; // this is typeorm Entity\nimport { Project } from \"../..\"; // this is typeorm Entity\nimport { User } from \"../..\"; // this is typeorm Entity\n\n// NOTICE: not arrow function here!\nexport const createUsersFixture = fixtureCreator<User>(User, function(\n  entity,\n  index\n) {\n  return {\n    email: `test${index}@mail.com`,\n    status: 10,\n    ...entity,\n    roles: many(this, Role, entity.roles)\n  };\n});\n\n// NOTICE: not arrow function here!\nexport const createProjectsFixture = fixtureCreator<Project>(Project, function(\n  entity,\n  index\n) {\n  return {\n    title: `Default Title`,\n    ...entity,\n    owner: one(this, User, entity.owner)\n  };\n});\n```\n\n#### 2. Create fixtures (each time for certain test)\n\n```typescript\nexport const usersFixture = createUsersFixture([\n  {\n    email: \"user@mail.com\",\n    roles: [{ name: \"user\" }] // roles will automatically added here (look usage)\n  },\n  {\n    email: \"admin@mail.com\",\n    roles: [{ name: \"user\" }, { name: \"admin\" }]\n  }\n]);\n\nexport const projectsFixture = createProjectsFixture([\n  {\n    owner: { email: \"admin@mail.com\" } // owner will automatically linked with user above\n  }\n]);\n```\n\n#### 3. Download data before test and drop after\n\n```typescript\nimport { TypeormFixtures } from \"typeorm-fixtures\";\n\nconst h = new TypeormFixtures()\n  .findEntities({ name: In([\"user\", \"admin\"]) }, Role) // sequence is important here!\n  .addFixture(usersFixture) // sequence is important here!\n  .addFixture(projectsFixture); // sequence is important here!\n\ndescribe(`GET /url`, async () => {\n  let projectId: number;\n  let user: User;\n\n  beforeAll(async () => {\n    await h.loadFixtures();\n    projectId = h.entities.Project[0].id; // this is our project id, which was loaded\n    user = h.entities.User.find(el => el.email === \"user@mail.com\"); // we also can find loaded user by email\n  });\n\n  afterAll(h.dropFixtures);\n\n  it(\"test\", async () => {\n    // now all data loaded to database and you can perform any actions here\n  });\n});\n```\n\n## Install\n\n```bash\nnpm i typeorm-fixtures --save-dev\n```\n\n```bash\nyarn add typeorm-fixtures --dev\n```\n\n## Stay in touch\n\n- Author - [Razzwan](https://t.me/Razzwan)\n\n## Thanks for helping\n\n- [Artem Batura](https://github.com/artemirq)\n- [Volodymyr Steblii](https://github.com/vsteblii)\n\n## License\n\nNest is [MIT licensed](LICENSE).\n\n## [Contributing](CONTRIBUTING.md)\n","readmeFilename":"README.md"}