Skip to content

Commit

Permalink
test: add unit tests and Jest configuration
Browse files Browse the repository at this point in the history
- Add basic test cases for BundleSizeAnalyzer
- Configure Jest with TypeScript support
- Add ts-jest and test dependencies
- Fix CI/CD test failures
  • Loading branch information
xanaawakens committed Jan 2, 2025
1 parent 0b2c1bb commit 205d1f1
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 118 deletions.
42 changes: 42 additions & 0 deletions __tests__/core.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { BundleSizeAnalyzer } from '../src/core/analyzer';

describe('BundleSizeAnalyzer', () => {
it('should be defined', () => {
const analyzer = new BundleSizeAnalyzer({
maxSize: 500,
outputFormat: 'json',
outputPath: './reports'
});
expect(analyzer).toBeDefined();
});

it('should initialize with correct options', () => {
const options = {
maxSize: 500,
outputFormat: 'json' as const,
outputPath: './reports'
};
const analyzer = new BundleSizeAnalyzer(options);
expect(analyzer).toHaveProperty('options.maxSize', options.maxSize);
expect(analyzer).toHaveProperty('options.outputFormat', options.outputFormat);
expect(analyzer).toHaveProperty('options.outputPath', options.outputPath);
});

it('should have default compression enabled', () => {
const analyzer = new BundleSizeAnalyzer({
maxSize: 500,
outputFormat: 'json',
outputPath: './reports'
});
expect(analyzer).toHaveProperty('options.compression', true);
});

it('should have empty rules by default', () => {
const analyzer = new BundleSizeAnalyzer({
maxSize: 500,
outputFormat: 'json',
outputPath: './reports'
});
expect(analyzer).toHaveProperty('options.rules', []);
});
});
Loading

0 comments on commit 205d1f1

Please sign in to comment.