An easy way to set test name in jest repetitive tests (test.each)

1 · Adrian Matei · March 3, 2023, 6:35 a.m.
One easy way to display a custom name for each test.each test in jest, is to place the text name in the first element of each array of the input table for the method and use it as name in the test.each method - ('%s', (testname, req, expectedBookmark) , as in the following snippet: const showdown = require('showdown'); const Bookmark = require('../../model/bookmark'); const bookmarkRequestMapper = require('./bookmark-request.mapper'); jest.mock('showdown', () => { const makeHtml = jest.fn(() ...