'single glob pattern to target all .test/.spec files TSConfig

I would like to exclude all test files in tsconfig.js. Files that should be excluded

*.test.ts
*.test.tsx
*.test.jsx
*.test.js
*.spec.ts
*.spec.tsx
*.spec.jsx
*.spec.js

I tried this

exclude: ["**/*.+(spec|test).{ts,tsx,js,jsx}"]

and this

exclude: [
  "**/*.+(spec|test).ts",
  "**/*.+(spec|test).tsx",
  "**/*.+(spec|test).js",
  "**/*.+(spec|test).jsx"
]

But it is not working. Is it necessary that we should specify each extension separately? Like

exclude: [
  "**/*.spec.ts",
  "**/*.spec.tsx",
  "**/*.test.ts",
  "**/*.test.tsx"
  // and goes on for .js and .jsx files
]

If YES, then what is the point of using glob pattern?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source