Skip to content

[DO NOT MERGE] Code snippet execution (Node.js)#24

Draft
alexcasalboni wants to merge 4 commits intomainfrom
code-snippet-execution-experiment
Draft

[DO NOT MERGE] Code snippet execution (Node.js)#24
alexcasalboni wants to merge 4 commits intomainfrom
code-snippet-execution-experiment

Conversation

@alexcasalboni
Copy link
Copy Markdown
Collaborator

@alexcasalboni alexcasalboni commented Jan 15, 2026

About the changes

This is an experiment to evaluate the idea of extracting major code snippets into independent files and run them as a test suite.

I tried an alternative approach with runme, but unfortunately it has too many markdown compatibility issues with Fern and I had to give up the idea of automatically identifying code snippets from the Markdown files. Besides the Fern incompatibility, the other major issue with the runme approach was that most snippets require some setup (like importing libraries), so we'd end up with too many weird hacks.

This is why I went for the "extract all the snippets into executable files" approach.

Pros:

  • Easier to integrate setup sections
  • Easier to target specific SDK versions over time (just a dependency in package.json for Node)
  • Easier to inject environment variables (a simple .env file) - although many snippets will need to be updated

Cons:

  • There's no automatic discovery - we need to extract every snippet into a new file and then reference it with a <Code> block
  • No built-in runner - we need to define ad-hoc test suites for each language/framework

Important files

  • new "sdks/examples/node" folder with a few Node.js SDK code snippets (with its own package.json to address a specific SDK version), plus a simple Vite test suite to run each file as a standalone test
  • new GitHub Action that runs the Node.js test suite as part of CI

Discussion points

This is not as low-effort as I thought initially:

  • extracting each individual snippet into its own file (or into a sequence of snippets) requires quite a bit of work
  • each programming language will require its own test suite, with different conventions, etc.
  • in CI, we should run all these different test suites
  • there are many other snippets that are not SDK-specific, so we might want to move the "examples" folder somewhere else, with only language-specific sub-folders, so that it's easier to run everything in CI

Feel free to take a look, run the existing Vite test suite locally, and close the PR if you think this is not worth it :)

@alexcasalboni alexcasalboni added the documentation Improvements or additions to documentation label Jan 15, 2026
@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant