{"id":21606274,"url":"https://github.com/zaydek/esnode-jest-consumer","last_synced_at":"2025-03-18T14:43:51.298Z","repository":{"id":91627625,"uuid":"345450960","full_name":"zaydek/esnode-jest-consumer","owner":"zaydek","description":"Working example directory for esnode-jest.","archived":false,"fork":false,"pushed_at":"2021-03-07T21:14:05.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-24T19:17:26.180Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zaydek.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":"2021-03-07T20:54:40.000Z","updated_at":"2021-03-07T21:14:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"386bf6be-f619-4de4-abd5-77da43dd11c8","html_url":"https://github.com/zaydek/esnode-jest-consumer","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/zaydek%2Fesnode-jest-consumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Fesnode-jest-consumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Fesnode-jest-consumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaydek%2Fesnode-jest-consumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaydek","download_url":"https://codeload.github.com/zaydek/esnode-jest-consumer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244244473,"owners_count":20422300,"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-11-24T20:20:24.021Z","updated_at":"2025-03-18T14:43:51.263Z","avatar_url":"https://github.com/zaydek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esnode-jest-consumer\n\nThis repo demonstrates how to start using Jest using esnode-jest. esnode-jest as the most minimal implementation needed\nto connect Jest to esbuild.\n\nOriginal [esnode-jest](https://github.com/zaydek/esnode-jest) repo here. This repo simply provides a starter example.\n\n## Installation\n\n```sh\nnpm add --dev @zaydek/esnode-jest\n\n# Or\n\nnpm i --save-dev @zaydek/esnode-jest\n```\n\nThe only other step to get started is created a `.babel.config.js` file at the root of your directory. If you’re curious\nwhy, you can learn more in the [implementation details](#implementation-details) section.\n\nIt should look like this:\n\n```js\n// babel.config.js\nmodule.exports = require(\"@zaydek/esnode-jest\")\n```\n\nIf you prefer to write a standard Jest configuration file, you may do so. The file `@zaydek/esnode-jest` references\nlooks like this, so you may use this instead or customize for your use case.\n\n\u003c!-- prettier-ignore --\u003e\n```js\n// https://jestjs.io/docs/en/getting-started#using-typescript\nmodule.exports = {\n  presets: [\n    [\"@babel/preset-env\", { targets: { node: \"current\" } }],\n    \"@babel/preset-typescript\",\n  ],\n}\n```\n\nThen create a TypeScript and TypeScript test file to start:\n\n```ts\n// greet.ts\nexport default function greet(who: string): string {\n\treturn `Hello, ${who}!`\n}\n```\n\n```ts\n// greet.test.ts\nimport greet from \"./greet\"\n\ntest(\"\", () =\u003e {\n\texpect(greet(\"world\")).toBe(\"Hello, world!\")\n})\n```\n\nThen on the command-line, run `./node_modules/.bin/jest` and you should see your test run and pass.\n\n## Implementation details\n\nHow this works: files are transpiled on demand by esbuild but Jest uses Babel internally for the test files. So your\nsource files (e.g. `source.ts`) are transformed by esbuild whereas your test files (e.g. `source.test.ts`) are\ntransformed by Babel. From what I understand, Babel is essential for `.test.ts` files but that’s it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaydek%2Fesnode-jest-consumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaydek%2Fesnode-jest-consumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaydek%2Fesnode-jest-consumer/lists"}