{"id":26770548,"url":"https://github.com/geoffdutton/cloudflare-vitest-plugin-workspace","last_synced_at":"2025-03-28T23:15:36.382Z","repository":{"id":281931977,"uuid":"946917298","full_name":"geoffdutton/cloudflare-vitest-plugin-workspace","owner":"geoffdutton","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-11T22:45:34.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T23:18:56.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/geoffdutton.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":"2025-03-11T22:00:24.000Z","updated_at":"2025-03-11T22:45:37.000Z","dependencies_parsed_at":"2025-03-11T23:28:59.345Z","dependency_job_id":null,"html_url":"https://github.com/geoffdutton/cloudflare-vitest-plugin-workspace","commit_stats":null,"previous_names":["geoffdutton/cloudflare-vitest-plugin-workspace"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoffdutton%2Fcloudflare-vitest-plugin-workspace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoffdutton%2Fcloudflare-vitest-plugin-workspace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoffdutton%2Fcloudflare-vitest-plugin-workspace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoffdutton%2Fcloudflare-vitest-plugin-workspace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geoffdutton","download_url":"https://codeload.github.com/geoffdutton/cloudflare-vitest-plugin-workspace/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246112665,"owners_count":20725301,"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":"2025-03-28T23:15:35.297Z","updated_at":"2025-03-28T23:15:36.376Z","avatar_url":"https://github.com/geoffdutton.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Vitest Workspace\n\nA minimal monorepo demonstrating Vitest with an npm workspace, tested with both the default Node.js pool and [@cloudflare/vitest-pool-workers](https://github.com/cloudflare/workers-sdk/tree/main/packages/vitest-pool-workers).\n\n## Structure\n\n```\nsimple-vitest-workspace/\n├── packages/\n│ └── core/\n│ ├── src/\n│ │ └── index.js # Simple add function\n│ ├── test/\n│ │ └── basic.test.js # Basic test for add\n│ └── package.json # Package config\n├── package.json # Root config with workspace\n├── vitest.config.js # Vitest config (Workers pool)\n└── README.md # This file\n```\n\n## Prerequisites\n\n- Node.js \u003e= 18.x\n- npm \u003e= 9.x\n\n## Setup\n\n```bash\n# Clone the repository\ngit clone \u003crepo-url\u003e\ncd simple-vitest-workspace\n\n# Install Dependencies\nnpm install\n```\n\n## Running Tests\n\n### With Default Node.js Pool\n\nEdit vitest.config.js to use the default pool:\n\n```javascript\nimport { defineConfig } from 'vitest/config'\n\nexport default defineConfig({\n  test: {\n    root: '.',\n    include: ['packages/*/test/*.test.js'],\n  },\n})\n```\n\nRun tests:\n\n```bash\nnpm test\n```\n\nExpected Output:\n\n```\nRUN v3.0.8 /path/to/simple-vitest-workspace\n✓ packages/core/test/basic.test.js (1)\n✓ should add two numbers\nTest Files 1 passed (1)\nTests 1 passed (1)\nDuration XXXms\n```\n\n### With Cloudflare Workers Pool\n\nUse the provided vitest.config.js (or ensure it matches):\n\n```javascript\nimport { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'\n\nexport default defineWorkersConfig({\n  test: {\n    root: '.',\n    include: ['packages/*/test/*.test.js'],\n    poolOptions: {\n      workers: {\n        main: 'packages/core/src/index.js',\n        singleWorker: true,\n        miniflare: {\n          compatibilityDate: '2025-03-10',\n        },\n      },\n    },\n  },\n})\n```\n\nRun tests:\n\n```bash\nnpm test\n```\n\nExpected Output:\n\n```\nRUN v3.0.8 /path/to/simple-vitest-workspace\n[vpw:inf] Starting single runtime for vitest.config.js...\n✓ packages/core/test/basic.test.js (1)\n✓ should add two numbers\nTest Files 1 passed (1)\nTests 1 passed (1)\nDuration XXXms\n[vpw:dbg] Shutting down runtimes...\n```\n\n## Purpose\n\nThis repo serves as a minimal reproducible example for:\n\n- A working Vitest setup in an npm workspace.\n- Integration with @cloudflare/vitest-pool-workers.\n\nIt was created to troubleshoot an issue where @cloudflare/vitest-pool-workers failed with TypeError: input.replace is not a function in a more complex project. In this simplified setup, both pools work, suggesting the original issue may stem from:\n\n- Absolute paths in include or main (fixed here with relative paths).\n- Project structure or config mismatches.\n\n## Original Issue\n\nIn a larger monorepo, using absolute paths like:\n\n```javascript\ninclude: ['/absolute/path/to/test/agent.spec.ts']\n```\n\nor\n\n```javascript\nmain: '/absolute/path/to/server-for-check.ts'\n```\n\ncaused:\n\n```\nTypeError: input.replace is not a function\nat normalizeWindowsPath (pathe.ff20891b.mjs:6:16)\nat relative (pathe.ff20891b.mjs:160:15)\nat createFileTask (@vitest/runner/dist/chunk-tasks.js:120:16)\n```\n\nSwitching to relative paths and globs resolved it here. If you encounter this, try:\n\n- Using relative paths (\"packages/_/test/_.js\", \"packages/core/src/index.js\").\n- Filing a bug at cloudflare/workers-sdk with your config and stack trace.\n\n## Dependencies\n\n- vitest: ^3.0.8\n- @cloudflare/vitest-pool-workers: Latest (check package.json)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoffdutton%2Fcloudflare-vitest-plugin-workspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeoffdutton%2Fcloudflare-vitest-plugin-workspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoffdutton%2Fcloudflare-vitest-plugin-workspace/lists"}