You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add comprehensive test suites for accessibility and code sample extraction scripts
Create Vitest configuration for running tests in Node environment
Refactor scripts to export functions for testability and conditional execution
Fix Babel import compatibility issues with default exports
Diagram Walkthrough
flowchart LR
A["Test Files Created"] -->|test extract-accessibility| B["cleanUpAccessibilityContent"]
A -->|test extract-code-samples| C["generateCodeForOneLiner"]
D["Vitest Config"] -->|configures| A
E["Script Refactoring"] -->|exports functions| B
E -->|exports functions| C
E -->|conditional execution| F["if process.argv check"]
G["Babel Import Fix"] -->|handles default exports| C
Loading
File Walkthrough
Relevant files
Configuration changes
vitest.config.ts
Vitest configuration for Node environment
packages/mcp/vitest.config.ts
Created new Vitest configuration file for the MCP package
Configured test environment as Node with globals enabled
Set test file pattern to **/__tests__/**/*.test.js
The integration test calls run() and asserts that at least one .md file exists in a real dist/generated/accessibility directory. This makes the test dependent on the local filesystem state and on the presence/shape of MDX files in docs, which can be flaky in CI or when run from different working directories. Consider isolating via a temp directory and/or mocking filesystem + input discovery so the test is deterministic and doesn’t leave artifacts behind.
describe("run - integration",()=>{it("should generate accessibility markdown files from MDX files",()=>{run();constoutputFiles=fs.readdirSync(outputDir).filter(f=>f.endsWith(".md"));expect(outputFiles.length).toBeGreaterThan(0);});
The integration test calls run() and checks for generated .md files under dist/generated. This introduces side effects and makes the test depend on existing Story files and write permissions. Prefer a temp output directory (passed into run/extractMarkdown) or mock fs/file discovery to keep tests hermetic.
describe("run - integration",()=>{it("should generate markdown files from story files",()=>{run();constoutputFiles=fs.readdirSync(outputDir).filter(f=>f.endsWith(".md"));expect(outputFiles.length).toBeGreaterThan(0);});
run() creates outputDir with fs.mkdirSync(outputDir) but without { recursive: true }. If parent directories don’t exist (common in clean CI checkouts), this can throw. Consider using { recursive: true } (as done in the other script) to avoid runtime failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
https://monday.monday.com/boards/3532714909/views/113184182/pulses/11227738642
PR Type
Tests, Enhancement
Description
Add comprehensive test suites for accessibility and code sample extraction scripts
Create Vitest configuration for running tests in Node environment
Refactor scripts to export functions for testability and conditional execution
Fix Babel import compatibility issues with default exports
Diagram Walkthrough
File Walkthrough
vitest.config.ts
Vitest configuration for Node environmentpackages/mcp/vitest.config.ts
**/__tests__/**/*.test.jsextract-accessibility.test.js
Test suite for accessibility content extractionpackages/mcp/scripts/tests/extract-accessibility.test.js
cleanUpAccessibilityContentfunctionbackticks
extract-code-samples.test.js
Test suite for code sample extractionpackages/mcp/scripts/tests/extract-code-samples.test.js
generateCodeForOneLinerfunctionextract-accessibility.js
Refactor for testability and exportspackages/mcp/scripts/extract-accessibility.js
getMdxFiles,extractAccessibilityFromMdx,cleanUpAccessibilityContent, andrunfunctions for testingrunfunction for bettertestability
process.argv[1]to allowmodule imports
extract-code-samples.js
Refactor for testability and Babel compatibilitypackages/mcp/scripts/extract-code-samples.js
getStoryFiles,generateCodeForOneLiner,extractMarkdown, andrunfunctionsfallback pattern
runfunctionprocess.argv[1]for moduleimports