I'm using jest
and ts-jest
configured in the way ts-jest
describes in their docs.
If I run yarn test --listTests
I can see the test file I want to run: processNewUser.ts
included in the output in a __test__
folder in my project.
I can run that test only with yarn test --testPathPattern='processNewUser'
But If I try use yarn test --testNamePattern='Processes new user. Auth'
which is the name of the test, then every test runs, including all with no name string like what is specified.
Same with:
yarn test -t="Auth"
yarn test -t Auth
yarn test --testNamePattern "Auth"
jest Auth
jest -t="Processes"
etc etc.
and every combo of syntax really. Also tried this with naming a describe
function wrapper instead of a test. No luck.
My tsconfig.json
is:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"outDir": "dist",
"sourceMap": true,
"allowJs": true,
"strict": true,
"noImplicitAny": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"removeComments": false,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"lib": [
"ES2020.Promise",
"ES2015.Iterable",
"ES2015.Symbol.WellKnown"
],
},
"include": ["src/**/*"],
}
My jest.config.ts
is:
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {
clearMocks: true,
coverageDirectory: 'coverage',
coverageProvider: 'v8',
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
preset: 'ts-jest',
setupFiles: ['dotenv/config'],
setupFilesAfterEnv: ['./jest.setup.js'],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.ts?$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/', '\\.pnp\\.[^\\/]+$'],
}
export default config;
Yarn script is just: "test": "jest",
I want this to be able to tag a test with auth
for example to have all auth tests run.
Any help?