Skip to content

Set up TanStack Start sample app with tests, CI/CD, and Bluehawk snippet extraction#101

Merged
tmcneil-mdb merged 4 commits into
development-frameworksfrom
frameworks-tanstack
May 4, 2026
Merged

Set up TanStack Start sample app with tests, CI/CD, and Bluehawk snippet extraction#101
tmcneil-mdb merged 4 commits into
development-frameworksfrom
frameworks-tanstack

Conversation

@tmcneil-mdb

@tmcneil-mdb tmcneil-mdb commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Overview

This PR establishes the complete workflow for the TanStack Start framework example, which serves as the tested source code for the MongoDB TanStack Start tutorial.

This sets up the foundation for maintaining framework examples as living, tested code that automatically generates documentation snippets.

What's Included

🎯 Complete TanStack Start Sample App

  • Restaurant browsing application demonstrating MongoDB integration
  • Server-side data fetching with TanStack Start
  • Client-side caching with TanStack Query
  • Full-stack TypeScript implementation

🧪 Comprehensive Test Suite (17 tests)

  • Unit tests (10 tests): Server functions with mocked MongoDB
  • Integration tests (7 tests): Full-stack queries with real database
  • Separate Vitest configs for unit vs integration testing
  • Test utilities using vite alias

🔄 CI/CD with GitHub Actions

  • Automated testing on push/PR to development and frameworks-tanstack branches
  • Sets up MongoDB using Atlas CLI
  • Runs both unit and integration tests
  • Generates test summaries with Vitest reporter

📚 Bluehawk Snippet Extraction

  • Generic snip.js script for all framework examples (reusable!)
  • Extracts 8 code snippets from annotated source files
  • Snippets committed directly to repo (no separate artifact repos)
  • Automated formatting with Prettier

📖 Documentation

  • Framework-specific README with tutorial link
  • Comprehensive test documentation
  • Component testing status explained (not implemented due to TanStack Start beta)

Key Review Areas

🔍 Please Review:

  1. GitHub Actions Workflow (.github/workflows/run-tanstack-tests.yml)

    • Does the CI setup make sense?
    • Test reporting working as expected?
  2. Bluehawk Snippet Extraction (frameworks/javascript/snip.js)

    • Generic script designed for all framework examples
    • Check path resolution and configuration handling
    • Verify snippet output in testedSnippets/
    • Do we like this pattern?
  3. Test Suite (frameworks/javascript/tanstack/tests/)

    • Are the test patterns appropriate?
    • Unit vs integration split makes sense?
    • Coverage is adequate for a sample app?

How to Test this PR

1.) Run the app locally

cd frameworks/javascript/tanstack/app
npm install
cp .env.example .env
# Add your MONGODB_URI to .env
npm run dev
# Visit http://localhost:3000

2.) Run tests

npm run test:all
  1. Extract snippets
cd frameworks/javascript/tanstack
npm install
npm run snip
# Check testedSnippets/ directory

Files Changed

  • New framework example structure in frameworks/javascript/tanstack/
  • Generic Bluehawk tooling in frameworks/javascript/
  • CI/CD workflow and test summary script

Testing

All tests passing locally:

cd frameworks/javascript/tanstack/app

npm run test:all       # 17 tests pass (unit + integration)
npm run test:unit      # 10 tests pass (~400ms)
npm run test:integration # 7 tests pass (~2s)

Bluehawk extraction verified:

cd frameworks/javascript/tanstack
npm run snip          # Generates 8 snippets

Known Limitations / Future Work

📌 Version Pinning (TODO - Separate PR)

  • TanStack Start version should be pinned to prevent breaking changes
  • Currently using "latest" in package.json
  • Should freeze to specific version once tutorial is published

🎨 Component Testing

  • Not implemented due to TanStack Start beta status
  • Known compatibility issues between TanStack Start plugin and Vitest
  • Documented in tests/README.md with more information
  • Will revisit when TanStack Start reaches v1.0

- Set up Bluehawk for snippet extraction from source code
- Add generic snip.js script for framework examples
- Add processFiles.js for handling unannotated files
- Extract 8 code snippets to testedSnippets/
- Add test:all npm script to run both unit and integration tests
- Update all READMEs to clarify test commands (test vs test:all)
- Document component testing status (not implemented due to TanStack Start beta)
- Add Bluehawk annotations to source files (Header, RestaurantList, db, routes)
Comment thread frameworks/javascript/tanstack/app/vite.config.ts
Comment thread frameworks/javascript/tanstack/app/package.json
Comment thread frameworks/javascript/tanstack/app/README.md Outdated
Comment thread frameworks/README.md
npm test

# Run only integration tests (requires MongoDB)
npm run test:integration

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get some failed tests even when connected to an atlas instance with sample data loaded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird. it worked with a local instance but not my atlas instance

@tmcneil-mdb tmcneil-mdb Apr 28, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I have not be able to successfully reproduce this bug. Do have the error messages? Does it fail every time or intermittently? Which tests were failing?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the integration tests. they're working now; my cluster didn't have any data actually loaded in the sample_restaurants db 🤷

Comment thread frameworks/README.md Outdated
Comment thread frameworks/javascript/tanstack/tests/README.md Outdated
Comment thread frameworks/javascript/tanstack/tests/README.md Outdated
Comment thread frameworks/javascript/snip.js Outdated
Comment thread frameworks/javascript/tanstack/tests/integration/restaurants.integration.test.ts Outdated
Comment thread frameworks/javascript/tanstack/tests/integration/restaurants.integration.test.ts Outdated
@tmcneil-mdb tmcneil-mdb requested a review from cbullinger April 28, 2026 23:49
@tmcneil-mdb tmcneil-mdb merged commit 6ab45e6 into development-frameworks May 4, 2026
2 checks passed
@tmcneil-mdb tmcneil-mdb deleted the frameworks-tanstack branch May 4, 2026 19:42
tmcneil-mdb added a commit that referenced this pull request May 4, 2026
* Set up TanStack Start sample app with tests, CI/CD, and Bluehawk snippet extraction (#101)

* Adding TanStack Start + Unit & Integration Tests

* Adding GH Actions

* Add Bluehawk snippet extraction and improve test documentation

- Set up Bluehawk for snippet extraction from source code
- Add generic snip.js script for framework examples
- Add processFiles.js for handling unannotated files
- Extract 8 code snippets to testedSnippets/
- Add test:all npm script to run both unit and integration tests
- Update all READMEs to clarify test commands (test vs test:all)
- Document component testing status (not implemented due to TanStack Start beta)
- Add Bluehawk annotations to source files (Header, RestaurantList, db, routes)

* addressing pr feedback

* Adding in copier flow (#104)
tmcneil-mdb added a commit that referenced this pull request May 7, 2026
…106)

* Bump pymongo to v4.17.0

* Merge TanStack Framework into Development (#105)

* Set up TanStack Start sample app with tests, CI/CD, and Bluehawk snippet extraction (#101)

* Adding TanStack Start + Unit & Integration Tests

* Adding GH Actions

* Add Bluehawk snippet extraction and improve test documentation

- Set up Bluehawk for snippet extraction from source code
- Add generic snip.js script for framework examples
- Add processFiles.js for handling unannotated files
- Extract 8 code snippets to testedSnippets/
- Add test:all npm script to run both unit and integration tests
- Update all READMEs to clarify test commands (test vs test:all)
- Document component testing status (not implemented due to TanStack Start beta)
- Add Bluehawk annotations to source files (Header, RestaurantList, db, routes)

* addressing pr feedback

* Adding in copier flow (#104)

* adding pining

* fix(python-fastapi): bump pillow and python-dotenv for security advisories

- pillow 12.2.0 (CVE-2026-42308 through CVE-2026-42311, GHSA-5xmw-vc9v-4wf2, etc.)
- python-dotenv 1.2.2 (CVE-2026-28684, GHSA-mf9w-mj56-hr94)

Addresses Dependabot alerts #47-51 on mongodb/docs-sample-apps.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cory Bullinger <cory.bullinger@mongodb.com>
Co-authored-by: cory <115956901+cbullinger@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
tmcneil-mdb added a commit that referenced this pull request May 27, 2026
* Bump pymongo to v4.17.0

* Merge TanStack Framework into Development (#105)

* Set up TanStack Start sample app with tests, CI/CD, and Bluehawk snippet extraction (#101)

* Adding TanStack Start + Unit & Integration Tests

* Adding GH Actions

* Add Bluehawk snippet extraction and improve test documentation

- Set up Bluehawk for snippet extraction from source code
- Add generic snip.js script for framework examples
- Add processFiles.js for handling unannotated files
- Extract 8 code snippets to testedSnippets/
- Add test:all npm script to run both unit and integration tests
- Update all READMEs to clarify test commands (test vs test:all)
- Document component testing status (not implemented due to TanStack Start beta)
- Add Bluehawk annotations to source files (Header, RestaurantList, db, routes)

* addressing pr feedback

* Adding in copier flow (#104)

* adding pining

* fix(python-fastapi): bump pillow and python-dotenv for security advisories

- pillow 12.2.0 (CVE-2026-42308 through CVE-2026-42311, GHSA-5xmw-vc9v-4wf2, etc.)
- python-dotenv 1.2.2 (CVE-2026-28684, GHSA-mf9w-mj56-hr94)

Addresses Dependabot alerts #47-51 on mongodb/docs-sample-apps.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Batch Dependabot Fixes & Security Workflow (#110)

* fix: dependabot issues and creating audit script

* chore:remove cached audit files

* chore: updating readme and gitignore

* fix: batch updating the python packages for mflix to sure the security passes

---------

Co-authored-by: Cory Bullinger <cory.bullinger@mongodb.com>
Co-authored-by: cory <115956901+cbullinger@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants