A modern monorepo for SvelteKit applications and shared packages, featuring comprehensive testing with Cucumber and Playwright, and automated CI/CD workflows.
SvelteLab is a pnpm monorepo that provides a scalable foundation for building SvelteKit applications with shared components and comprehensive testing infrastructure. It features:
SvelteLab/
โโโ .github/
โ โโโ workflows/ # GitHub Actions CI/CD workflows
โ โโโ ci.yml # Main CI pipeline
โ โโโ deploy.yml # Production deployment
โ โโโ preview.yml # Preview deployments
โ โโโ dependency-review.yml # Security scanning
โ โโโ release.yml # Automated releases
โโโ apps/
โ โโโ my-playground/ # SvelteKit application
โ โโโ src/
โ โโโ static/
โ โโโ package.json
โ โโโ svelte.config.js
โโโ packages/
โ โโโ ui/ # Shared UI components (ready for expansion)
โโโ tests/
โ โโโ playwright/ # Cucumber + Playwright testing
โ โโโ features/ # Cucumber feature files
โ โโโ support/ # Step definitions and hooks
โ โโโ cucumber.js # Cucumber configuration
โ โโโ package.json
โโโ pnpm-workspace.yaml # Workspace configuration
โโโ package.json # Root configuration
โโโ README.md # This file
Clone the repository:
git clone <your-repo-url>
cd SvelteLab
Install dependencies:
pnpm install
Start the development server:
pnpm playground:dev
Open your browser: Navigate to http://localhost:5173
# Development
pnpm playground:dev # Start development server
pnpm playground:build # Build for production
pnpm playground:preview # Preview production build
pnpm playground:check # Type checking
pnpm playground:lint # Lint code
pnpm playground:test # Run app-specific tests
# Cucumber Tests (BDD)
pnpm test:cucumber # Run all Cucumber tests
pnpm test:cucumber:parallel # Run tests in parallel
pnpm test:cucumber:headed # Run with visible browser
pnpm test:cucumber:debug # Run debug tests only
# Root level
pnpm dev # Start default app (currently playground)
pnpm build # Build default app
pnpm lint # Lint all packages
pnpm test # Run all tests
Start Development:
pnpm playground:dev
Run Tests (in another terminal):
pnpm test:cucumber
Check Code Quality:
pnpm playground:lint
pnpm playground:check
The project uses Cucumber with Playwright for behavior-driven development testing.
tests/
โโโ playwright/ # Cucumber + Playwright workspace
โโโ features/
โ โโโ playground.feature # Gherkin feature files
โโโ support/
โ โโโ world.ts # Custom World with Playwright
โ โโโ hooks.ts # Cucumber lifecycle hooks
โ โโโ steps.ts # Step definitions
โโโ cucumber.js # Configuration
โโโ package.json # Test dependencies
# From root directory
pnpm test:cucumber
# From tests/playwright directory
cd tests/playwright
pnpm cucumber
# With visible browser
pnpm test:cucumber:headed
# Parallel execution
pnpm test:cucumber:parallel
Feature File Example:
Feature: User Authentication
As a user
I want to log in to the application
So that I can access my account
Background:
Given I am on the homepage
Scenario: Successful login
When I enter valid credentials
And I click the login button
Then I should be redirected to the dashboard
Step Definition Example:
import { Given, When, Then } from "@cucumber/cucumber";
import { expect } from "@playwright/test";
import { CustomWorldClass } from "./world";
const BASE_URL = process.env.BASE_URL || 'http://localhost:5173';
Given("I am on the homepage", async function (this: CustomWorldClass) {
await this.page!.goto(BASE_URL);
});
When("I enter valid credentials", async function (this: CustomWorldClass) {
// Implementation here
});
report/playwright/cucumber-report.html
report/playwright/cucumber-report.json
The project includes comprehensive GitHub Actions workflows for automated testing, security scanning, and deployment.
.github/workflows/ci.yml
)Triggers: Push to main
/develop
, Pull Requests
Features:
svelte-check
pnpm audit
.github/workflows/dependency-review.yml
)Triggers: Pull Requests
Features:
.github/workflows/preview.yml
)Triggers: PRs and pushes to develop
Features:
.github/workflows/deploy.yml
)Triggers: Push to main
, manual dispatch
Features:
.github/workflows/release.yml
)Triggers: Git tags (v*
)
Features:
The CI/CD system supports flexible configuration through environment variables:
# Testing
BASE_URL=http://localhost:5173 # Default for local development
BASE_URL=http://localhost:4173 # Used in CI for preview builds
# CI Environment
CI=true # Enables CI-specific optimizations
NODE_ENV=production # For production builds
Recommended branch protection rules for main
:
# pnpm-workspace.yaml
packages:
- "apps/*"
- "packages/*"
- "tests/playwright"
Create a new app:
cd apps
pnpm create svelte@latest my-new-app
cd my-new-app
pnpm install
Add scripts to root package.json:
{
"scripts": {
"newapp:dev": "pnpm --filter my-new-app dev",
"newapp:build": "pnpm --filter my-new-app build"
}
}
Update workspace configuration (if needed)
Create .env
files for environment-specific configuration:
# .env.local
VITE_API_URL=http://localhost:3000
VITE_APP_TITLE=SvelteLab
Each package has its own tsconfig.json
with proper module resolution and path mapping.
// tests/cucumber.js
module.exports = {
default: {
requireModule: ["ts-node/register"],
require: ["support/*.ts"],
format: ["@cucumber/pretty-formatter"],
paths: ["features/*.feature"],
parallel: 2,
timeout: 30000,
},
};
tests/features/
tests/support/steps.ts
# Check code quality
pnpm playground:lint
pnpm playground:check
# Format code
pnpm playground:format
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! ๐