{"id":19572932,"url":"https://github.com/erickwendel/recreating-nodejs-test-runner","last_synced_at":"2025-04-27T05:32:04.289Z","repository":{"id":243395321,"uuid":"812259395","full_name":"ErickWendel/recreating-nodejs-test-runner","owner":"ErickWendel","description":"An crazy experiment recreating the Node.js test runner (with no libraries) using the same componentes of the original project","archived":false,"fork":false,"pushed_at":"2024-06-10T12:30:52.000Z","size":654,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-11T12:25:55.702Z","etag":null,"topics":["asynchooks","asynclocalstorage","docker","javascript","node-test-runner","nodejs","test","test-runner"],"latest_commit_sha":null,"homepage":"https://erickwendel.github.io/recreating-nodejs-test-runner/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ErickWendel.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-08T11:40:33.000Z","updated_at":"2024-06-11T06:44:51.000Z","dependencies_parsed_at":"2024-06-08T15:50:14.313Z","dependency_job_id":"dcbcc3c3-14b0-4f7f-8bbc-db01aea51e7f","html_url":"https://github.com/ErickWendel/recreating-nodejs-test-runner","commit_stats":null,"previous_names":["erickwendel/recreating-nodejs-test-runner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErickWendel%2Frecreating-nodejs-test-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErickWendel%2Frecreating-nodejs-test-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErickWendel%2Frecreating-nodejs-test-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErickWendel%2Frecreating-nodejs-test-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ErickWendel","download_url":"https://codeload.github.com/ErickWendel/recreating-nodejs-test-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224060427,"owners_count":17249022,"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":["asynchooks","asynclocalstorage","docker","javascript","node-test-runner","nodejs","test","test-runner"],"created_at":"2024-11-11T06:31:00.089Z","updated_at":"2024-11-11T06:31:21.510Z","avatar_url":"https://github.com/ErickWendel.png","language":"JavaScript","readme":"# Node.js Custom Test Runner Experiment\n\n[![Build Status](https://github.com/ErickWendel/recreating-nodejs-test-runner/workflows/Test%20Runner%20EW/badge.svg)](https://github.com/ErickWendel/recreating-nodejs-test-runner/actions)\n\n\n## Introduction\n\nThis project is an experiment where I recreate the Node.js test runner using the same components. The primary goal is to understand and demonstrate the functionality of the test runner using:\n\n- Parallelism with Child Processes\n- AsyncHooks and Async LocalStorage for tracking the origin and retrieving the entire tree of tests.\n- Testing API with hooks such as `describe`, `it`, `before`, `after`, `beforeEach`, `afterEach`\n\n## Project Structure\n\n- **[app](./app/)**: Contains a complete project which is an API with a comprehensive test suite. This suite tests each individual route and uses the custom test runner to prove the experiment's functionality.\n\n## Test Runner Components\n\nThis custom test runner follows all the steps a test runner needs to have:\n\n- **Executor**: Located at [./test-runner/bin/test-runner.js](./test-runner/bin/test-runner.js)\n- **Formatter**: Located at [./test-runner/bin/reporter.js](./test-runner/bin/reporter.js)\n- **JS API for Hooks**: Located at [./test-runner/module/testRunner.js](./test-runner/module/testRunner.js)\n\n### Role of AsyncHooks\n\n`AsyncHooks` are crucial for this project as they allow tracking the origin and retrieving the entire tree of tests. This helps in understanding which `describe` block all hooks belong to. Using `AsyncHooks`, the context of asynchronous operations is maintained, ensuring that hooks like `before`, `after`, `beforeEach`, and `afterEach` are correctly associated with their respective test cases.\n\n## Getting Started\n\n### Prerequisites\n\nEnsure you have the following installed:\n\n- Node.js (\u003e=20.14)\n- Docker and docker-compose (for executing [./app](./app/))\n\n### Installation\n\n```sh\ngit clone https://github.com/ErickWendel/recreating-nodejs-test-runner.git\n```\n\n## Complete app\n```sh\ncd recreating-nodejs-test-runner/app\ndocker-compose up -d\nnpm test\n```\n![](./demo2.png)\n\n## Test runner Example\n\nClone the repository and install the dependencies:\n\n```sh\ncd recreating-nodejs-test-runner/test-runner\nnpm test\n```\n![](./demo.png)\n\n## Try at home!\n\nSee at [the example](./test-runner/tests/example.test.js) and execute one of your applications there :)\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any changes or improvements.\n\n## License\n\nThis project is licensed under the MIT License.\n\n---\n## Todo\n\n- add feature so before and beforeEach executes inside sub suites\n- fix log\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickwendel%2Frecreating-nodejs-test-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferickwendel%2Frecreating-nodejs-test-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickwendel%2Frecreating-nodejs-test-runner/lists"}