feat(tstest): Enhance tstest with fluent API, suite grouping, tag filtering, fixture & snapshot testing, and parallel execution improvements
This commit is contained in:
52
test/tapbundle/test.snapshot.ts
Normal file
52
test/tapbundle/test.snapshot.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { tap, expect } from '../../ts_tapbundle/index.js';
|
||||
|
||||
// Test basic snapshot functionality
|
||||
tap.tags('unit', 'snapshot')
|
||||
.test('should match string snapshot', async (toolsArg) => {
|
||||
const testString = 'Hello, World!';
|
||||
await toolsArg.matchSnapshot(testString);
|
||||
});
|
||||
|
||||
// Test object snapshot
|
||||
tap.tags('unit', 'snapshot')
|
||||
.test('should match object snapshot', async (toolsArg) => {
|
||||
const testObject = {
|
||||
name: 'Test User',
|
||||
age: 30,
|
||||
hobbies: ['reading', 'coding', 'gaming'],
|
||||
metadata: {
|
||||
created: '2024-01-01',
|
||||
updated: '2024-01-15'
|
||||
}
|
||||
};
|
||||
await toolsArg.matchSnapshot(testObject);
|
||||
});
|
||||
|
||||
// Test named snapshots
|
||||
tap.tags('unit', 'snapshot')
|
||||
.test('should handle multiple named snapshots', async (toolsArg) => {
|
||||
const config1 = { version: '1.0.0', features: ['a', 'b'] };
|
||||
const config2 = { version: '2.0.0', features: ['a', 'b', 'c'] };
|
||||
|
||||
await toolsArg.matchSnapshot(config1, 'config_v1');
|
||||
await toolsArg.matchSnapshot(config2, 'config_v2');
|
||||
});
|
||||
|
||||
// Test dynamic content with snapshot
|
||||
tap.tags('unit', 'snapshot')
|
||||
.test('should handle template snapshot', async (toolsArg) => {
|
||||
const template = `
|
||||
<div class="container">
|
||||
<h1>Welcome</h1>
|
||||
<p>This is a test template</p>
|
||||
<ul>
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
</ul>
|
||||
</div>
|
||||
`.trim();
|
||||
|
||||
await toolsArg.matchSnapshot(template, 'html_template');
|
||||
});
|
||||
|
||||
tap.start();
|
Reference in New Issue
Block a user