Thanks to visit codestin.com
Credit goes to github.com

Skip to content

%% is not replaced correctly in name of test.eachΒ #11356

@frozenbonito

Description

@frozenbonito

πŸ› Bug Report

  1. %% consume an argument.
  2. When there is a character used in a format specifier such as d or s immediately after %% (e.g. %%d), % replaced from %% is considered as a prefix of format specifier.

To Reproduce

Steps to reproduce the behavior:

index.test.js

describe("test name should to be %", () => {
  test.each([[1, 2, 3]])("%%", (a, b, expected) => {
    expect(a + b).toBe(expected);
  });
});

describe("test name should to be %d", () => {
  test.each([[1, 2, 3]])("%%d", (a, b, expected) => {
    expect(a + b).toBe(expected);
  });
});

Run npx jest, then you can see the following:

$ npx jest
 PASS  ./index.test.js
  test name should to be %
    βœ“ % 1 (1 ms)
  test name should to be %d
    βœ“ 2 1

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.244 s, estimated 1 s
Ran all test suites.

Expected behavior

$ npx jest
 PASS  ./index.test.js
  test name should to be %
    βœ“ % (1 ms)
  test name should to be %d
    βœ“ %d

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.244 s, estimated 1 s
Ran all test suites.

Link to repl or repo (highly encouraged)

envinfo

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    npm: 7.11.1 - ~/.nvm/versions/node/v14.16.1/bin/npm
  npmPackages:
    jest: ^26.6.3 => 26.6.3 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions