In the Jest documentation, the default value for the testMatch configuration option is [ “/tests//.[jt]s?(x)”, “**/?(.)+(spec|test).[jt]s?(x)” ]. My question is, since we want to match file extensions like .js, .jsx, .ts, and .tsx, why is it not .[jt]sx??
There are two places I don’t quite understand:
- The character ‘s’ must appear.
- Why is ‘x’ placed in a group?
Thank you very much.
I did the following test on regex101.com, and it seems that .[jt]s?(x) does not match as expected.