Parameterised tests for Jest that enable running the same test multiple times with different data sets using arrays or tagged template literals
85
Build a custom code transformer for Jest that transforms TypeScript files and preserves source maps for accurate error reporting and debugging.
You need to create a Jest transformer that converts TypeScript code to JavaScript while maintaining source map information. This transformer should integrate into Jest's transformation pipeline and ensure that stack traces and error messages point to the original TypeScript source locations, not the compiled JavaScript.
Your transformer must:
.ts filesCreate a Jest configuration that:
.ts file extensions to your custom transformerWrite tests that verify:
@generates
import type { TransformOptions, TransformedSource } from '@jest/transform';
/**
* Custom Jest transformer that converts TypeScript to JavaScript
* and preserves source maps for accurate debugging
*/
export function process(
sourceText: string,
sourcePath: string,
options: TransformOptions
): TransformedSource;
/**
* Returns cache key for the transformer to enable proper caching
*/
export function getCacheKey?(
sourceText: string,
sourcePath: string,
options: TransformOptions
): string;Provides transformer types and interfaces for Jest's transformation pipeline.
TypeScript compiler for transforming TypeScript code to JavaScript.
Install with Tessl CLI
npx tessl i tessl/npm-jest-eachdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10