ssssota / doc-vitest Goto Github PK
View Code? Open in Web Editor NEWDocumentation tests with Vitest
Home Page: https://npmjs.com/vite-plugin-doctest
Documentation tests with Vitest
Home Page: https://npmjs.com/vite-plugin-doctest
I have a fairly simple use case where I'm trying to test code snippets in README.md. However, vitest gives Error: Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .md file format, or if it's an asset, add "**/*.md" to
assetsInclude in your configuration.
. Any idea what could be wrong?
vite.config.ts:
export default defineConfig({
plugins: [doctest(), dts({ rollupTypes: true })],
test: {
includeSource: ["./src/**/*.[jt]s?(x)", "./README.md"],
},
...
})
versions:
"vite": "^5.2.11",
"vite-plugin-doctest": "^1.0.0",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0",
full error stack:
Error: Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .md file format, or if it's an asset, add "**/*.md" to `assetsInclude` in your configuration.
❯ formatError node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:50830:46
❯ TransformContext.error node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:50824:19
❯ TransformContext.transform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:66069:22
❯ Object.transform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:51139:30
❯ loadAndTransform node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:53894:29
for GitHub Actions
Hello! Thank you for this plugin. I sorely missed doctests, coming from Rust.
Here is a minimum example of the issue:
class Foo {
public constructor() { }
/** some note about this property */ // ← this causes the test discovery to fail
private readonly bar: number = 3;
/**
* @import.meta.vitest
* ```ts
* assert(false);
* ```
*/
public readonly baz = (): void => { }
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.