jest-serializer-xlsx-populate

2.0.0 • Public • Published

Serializer for XLSX Workbooks

Turn an xlsx-populate workbook into a pretty snapshot.

The serializer will also look for columns marked as ID or Date and mask them, as these will normally change from test to test.

Usage

First you need to add the snapshot serializer. You have two options:

  1. Expect.addSerializer
const xlsxPopulateSerializer = require('jest-serializer-xlsx-populate');
expect.addSnapshotSerializer(xslxPopulateSerializer);
  1. Jest config

for example in package.json

{
  "name": "my project",
  "jest": {
    "snapshotSerializers": ["jest-serializer-xlsx-populate"]
  }
}

Then you can serialize

const wb = await XlsxPopulate.fromFileAsync('my-file.xlsx');
expect(wb).toMatchSnapshot();

Of course since you're using xlsx populate to create an xlsx file, it will probably be easier to test the Workbook before saving to disk.

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i jest-serializer-xlsx-populate

    Weekly Downloads

    4

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    6.58 kB

    Total Files

    4

    Last publish

    Collaborators

    • jwickens