New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@formfeed/testing

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formfeed/testing

Vitest and Jest matchers for Formfeed templates: render without errors, use only known variables, snapshots.

latest
Source
npmnpm
Version
0.3.10
Version published
Weekly downloads
855
140.85%
Maintainers
1
Weekly downloads
 
Created
Source

@formfeed/testing

Vitest and Jest matchers for Formfeed HTML templates kept in your repository. The offline matchers render with the same engine the API uses, so they need no account. Word and PowerPoint templates are tested with formfeed test, which compares their filled XML with approved snapshots.

npm install -D @formfeed/testing

Register the matchers once: add @formfeed/testing/vitest to Vitest's setupFiles, or @formfeed/testing/jest to Jest's setupFilesAfterEnv.

import { loadTemplate } from '@formfeed/testing';
import invoice from '../templates/invoice-de/data/default.json';

const tpl = await loadTemplate('templates/invoice-de');

test('compiles and uses only known variables', async () => {
  await expect(tpl).toRenderWithoutErrors(invoice);
  await expect(tpl).toUseOnlyKnownVariables(invoice);
});

test('html snapshot', async () => {
  expect(await tpl.render(invoice)).toMatchSnapshot();
});

test('two pages for forty lines', async () => {
  await expect(tpl).toHavePageCount(2, invoice); // a true render through the API
});
MatcherNeeds the APIChecks
toRenderWithoutErrors(data)noCompiles and renders without engine errors
toUseOnlyKnownVariables(data)noEvery variable the template reads exists in the data
toContainText(text, data)noThe rendered HTML contains the text
toHavePageCount(n, data)yesPage count of the true render

API-backed matchers read FORMFEED_API_KEY (a test key is enough) and skip with a warning without one; set FORMFEED_REQUIRE_API=1 in CI to make them fail instead. For another test runner, pass matchers to its expect.extend.

Documentation

  • Testing templates

Licence

MIT

Keywords

formfeed

FAQs

Package last updated on 25 Sep 2026

Related posts