Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR Validation

on:
pull_request:
branches: [main]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Type check
run: npm run typecheck

- name: Build
run: npm run build

- name: Test
run: npm run test
27 changes: 27 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @type {import('jest').Config} */
const config = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.test.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
collectCoverageFrom: [
'src/exporter/**/*.ts',
'src/prompts/**/*.ts',
'!src/**/*.d.ts',
],
};

module.exports = config;
44 changes: 44 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Jest setup file for ClankerContext tests
// This file runs before each test suite

import type { MatcherFunction } from 'expect';

const toHaveNoUnrenderedTokens: MatcherFunction<[]> = function (received: unknown) {
if (typeof received !== 'string') {
return {
message: () => `Expected a string but received ${typeof received}`,
pass: false,
};
}

const tokenRegex = /{{[a-zA-Z0-9_.#/]+}}/g;
const matches = received.match(tokenRegex);

if (matches && matches.length > 0) {
return {
message: () =>
`Expected no unrendered tokens but found: ${matches.join(', ')}`,
pass: false,
};
}

return {
message: () => 'Expected unrendered tokens but found none',
pass: true,
};
};

expect.extend({
toHaveNoUnrenderedTokens,
});

// Type augmentation for custom matchers
declare global {
namespace jest {
interface Matchers<R> {
toHaveNoUnrenderedTokens(): R;
}
}
}

export {};
Loading