Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-each-table

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-each-table

Create a test-case table for use with Jest's test.each tagged template literal

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
decreased by-11.81%
Maintainers
1
Weekly downloads
 
Created
Source

jest-each-table

Take advantage of jest's test.each tagged template literal functionality without needing to hardcode the test-cases as template literals.

Usage

import createTestTable from 'jest-each-table';

const testcases = createTestTable(
  [...Array(10)].map((_, i) => ({
    inputs: { left: i, right: i },
    output: i + i
  }))
);

const testsuite = test.each(...testcases);

testsuite('$inputs.left + $inputs.right = $output', ({ inputs, output }) => {
  expect(inputs.left + inputs.right).toBe(output);
});

Context

Jest's test.each functionality can be used in two ways:

  1. test.each (function): This allows an Array of Arrays with the arguments that are passed into the test fn for each row.
  2. test.each (tagged template literal): This allows a table of test-cases to be defined as an ES2015 string template.

Unfortunately test.each (the function) uses printf formatting for creating the test title which has serious drawbacks compared to how the title is formatted using test.each (the tagged template literal) which supports $variable.

FAQs

Package last updated on 24 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc