Jörgen
Jörgen

Reputation: 316

Jest test runner fails on certain characters in test string

Let's say I write a Jest test case as:

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

and then run it as:

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

It works fine.

However if I add a '+' sign to my test case string as:

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

and then run it as:

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

Jest will fail to run the test. Is this documented/configurable somewhere?

Upvotes: 0

Views: 163

Answers (1)

Baka
Baka

Reputation: 146

-t (--testNamePattern) expects regex, escape + with backslash like this: -t "encode \+ bar"

Upvotes: 1

Related Questions