Jest 测试运行程序在测试字符串中的某些字符上失败

Jest test runner fails on certain characters in test string

假设我将 Jest 测试用例编写为:

test('encode bar', () => {
   let foo = encodeBar();
   expect(foo).toEqual("bar");
});

然后 运行 为:

node node_modules/.bin/jest --no-coverage -t "encode bar"

它工作正常。

但是,如果我将“+”符号添加到我的测试用例字符串中,如下所示:

test('encode + bar', () => {
   let foo = encodeBar();
   expect(foo).toEqual("bar");
});

然后 运行 为:

node node_modules/.bin/jest --no-coverage -t "encode + bar"

Jest 将无法通过 运行 测试。 这是documented/configurable在什么地方吗?

-t (--testNamePattern) 需要正则表达式,使用反斜杠转义 +,如下所示:-t "encode \+ bar"