{"id":23885954,"url":"https://github.com/danielcaldas/test-fixtures-pattern","last_synced_at":"2025-04-10T01:23:40.406Z","repository":{"id":44481776,"uuid":"212591304","full_name":"danielcaldas/test-fixtures-pattern","owner":"danielcaldas","description":"A simple demonstration of a fixtures test based architecture in JavaScript","archived":false,"fork":false,"pushed_at":"2023-02-18T15:09:36.000Z","size":654,"stargazers_count":10,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T03:04:59.760Z","etag":null,"topics":["architectural-patterns","javascript","jest","testing","unit-testing"],"latest_commit_sha":null,"homepage":"https://goodguydaniel.com/blog/unit-testing-with-fixtures-unleashed/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielcaldas.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":"2019-10-03T13:47:07.000Z","updated_at":"2024-07-05T10:10:17.000Z","dependencies_parsed_at":"2023-02-02T21:30:26.585Z","dependency_job_id":null,"html_url":"https://github.com/danielcaldas/test-fixtures-pattern","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielcaldas%2Ftest-fixtures-pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielcaldas%2Ftest-fixtures-pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielcaldas%2Ftest-fixtures-pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielcaldas%2Ftest-fixtures-pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielcaldas","download_url":"https://codeload.github.com/danielcaldas/test-fixtures-pattern/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248138693,"owners_count":21053925,"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":["architectural-patterns","javascript","jest","testing","unit-testing"],"created_at":"2025-01-04T05:56:10.306Z","updated_at":"2025-04-10T01:23:40.377Z","avatar_url":"https://github.com/danielcaldas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unit testing with fixtures unleashed\nThis repository is just an example for explaining how fixtures can be set up in within a project, you can read more about it [in this blog post](https://goodguydaniel.com/blog/unit-testing-with-fixtures-unleashed/).\n\nA simple demonstration of a fixtures test based architecture in JavaScript. A simple case study scenario is built around a function called `backgroundColorReplacer` that is exposed in main *entroypoint* file `replacer.js`.\n\n## The case study\nThere's a dummy implementation of a function called `backgroundColorReplacer` that basically replaces a `background-color` css property with a `rgb` color for some other `rgb` or `rgba` color depending on the options passed to this function.\n\nExamples of usage can be seen in the file `__tests__/replacer.test.js`.\n\n### Unit tests\nSome simple unit tests are added in `__tests__/replacer.test.js`, as a first step.\n\u003csmall\u003ebranch: step-1-implementation-and-unit-tests\u003c/small\u003e\n\n### Fixtures architecture\nAt the end, we get a set of organized test cases within the `fixtures` folder, that are consumed from `run-fixtures.js` that will generate all the *jest boilerplatish* code for us. Each test case within `fixtures` has a very specific name that depicts its purpose, also the content of these files is strictly declarative,\nthe only thing there are the specification of the inputs for our replacer.\n\n```\nfixtures\n├── not-replace-color-if-no-match.js\n├── not-replace-color-if-no-new-color-specified.js\n├── replace-color-when-match-and-opacity-defined.js\n├── replace-color-when-match.js\n└── tests\n    ├── fixtures.spec.js\n    └── __snapshots__\n        └── fixtures.spec.js.snap\nrun-fixtures.js\n```\n\n- `fixtures` - folder where test cases are specified.\n- `run-fixtures` - responsible for generating `fixtures/tests/fixtures.spec.js`, where the actual tests are outputted.\n\n✍️ [\"Unit testing with fixtures unleashed\"](https://goodguydaniel.com/blog/unit-testing-with-fixtures-unleashed/) @ [goodguydaniel.com](https://goodguydaniel.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielcaldas%2Ftest-fixtures-pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielcaldas%2Ftest-fixtures-pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielcaldas%2Ftest-fixtures-pattern/lists"}