A Jest transformer that precompiles Svelte components for testing, supporting both ESM and CJS.
svelte-jester is a Jest transformer for Svelte applications. It compiles Svelte components into JavaScript modules that Jest can understand, enabling unit and integration testing for Svelte projects. It solves the problem of Jest being unable to directly import and test .svelte files by handling the necessary precompilation.
Developers using Jest as their test runner in Svelte projects, particularly those working with Svelte 4+ (ESM) or Svelte 3 (CJS), and those requiring preprocessor support for TypeScript, SCSS, or other compile-time transformations.
Developers choose svelte-jester for its active maintenance, reliable preprocessor support, and straightforward configuration, addressing gaps found in other libraries. It offers unique flexibility with ESM/CJS support, configurable compiler options, and root mode configuration for monorepos.
A Jest transformer for Svelte - compile your components before importing them into tests.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The README emphasizes that svelte-jester addresses maintenance gaps and preprocessor support issues found in other libraries, ensuring reliability for long-term projects.
It seamlessly supports svelte-preprocess for TypeScript, SCSS, and other compile-time transformations, enabling comprehensive testing of modern Svelte components.
Offers both ESM and CJS versions, accommodating Svelte 4+ projects requiring ESM and backward compatibility with Svelte 3 using CommonJS.
The 'upward' root mode allows locating svelte.config.js files in nested directories, making it adaptable for complex monorepo structures without redundant configs.
In CommonJS mode, preprocessors require spawning a new Node process for each file, which the README admits adds significant performance overhead and can slow down tests.
ESM mode relies on Jest's experimental VM modules, necessitating Node flags like --experimental-vm-modules and facing potential instability or breaking changes.
Manual installation involves multiple steps, including Jest transform tweaks and optional preprocessor setup, which can be error-prone and time-consuming for newcomers.