Need some help on collecting coverage in workers.

I know that the coverage via V8 is not possible, but via istanbul it does not collect coverage as well. Getting this error
TypeError: this.toSlices is not a function or its return value is not iterable
IstanbulCoverageProvider.reportCoverage ../../node_modules/@vitest/coverage-istanbul/dist/provider.js:214:34
Vitest.reportCoverage ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6537:7
async file:/Users/ashrith/Development/react/feedback-circuit/feedback-circuit/node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6328:7
Vitest.runFiles ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6332:12
Vitest.start ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6223:7
startVitest ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:13380:5
start ../../node_modules/vitest/dist/cli.js:1386:17
CAC.run ../../node_modules/vitest/dist/cli.js:1367:3
TypeError: this.toSlices is not a function or its return value is not iterable
IstanbulCoverageProvider.reportCoverage ../../node_modules/@vitest/coverage-istanbul/dist/provider.js:214:34
Vitest.reportCoverage ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6537:7
async file:/Users/ashrith/Development/react/feedback-circuit/feedback-circuit/node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6328:7
Vitest.runFiles ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6332:12
Vitest.start ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:6223:7
startVitest ../../node_modules/vitest/dist/vendor/cli-api.RIYLcWhB.js:13380:5
start ../../node_modules/vitest/dist/cli.js:1386:17
CAC.run ../../node_modules/vitest/dist/cli.js:1367:3
Any help is appreciated, thanks!
1 Reply
Ashrith
Ashrith2mo ago
Adding additional Information Created a worker using bun create cloudflare\@2.5.0 My vitest.config.ts
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';

export default defineWorkersConfig({
test: {
coverage: {
provider: 'istanbul'
},
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
},
},
},
});
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';

export default defineWorkersConfig({
test: {
coverage: {
provider: 'istanbul'
},
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
},
},
},
});
My package.json dev deps
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.1.0",
"@cloudflare/workers-types": "^4.20240402.0",
"@vitest/coverage-istanbul": "^1.4.0",
"typescript": "^5.0.4",
"vitest": "1.3.0",
"wrangler": "^3.0.0"
}
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.1.0",
"@cloudflare/workers-types": "^4.20240402.0",
"@vitest/coverage-istanbul": "^1.4.0",
"typescript": "^5.0.4",
"vitest": "1.3.0",
"wrangler": "^3.0.0"
}
Running the test in the hello world template for the example test provided This issue is with the latest version of vitest, raised an issue there! if anyone using 1.4.0 please use 1.3.0