Skip to content

Instantly share code, notes, and snippets.

@Roms1383
Created January 16, 2020 05:11
Show Gist options
  • Save Roms1383/67664bc9c857688613a2520b92aed157 to your computer and use it in GitHub Desktop.
Save Roms1383/67664bc9c857688613a2520b92aed157 to your computer and use it in GitHub Desktop.
Medium - Dynamically matching files in Jest - using environment variable
JEST_FILES_PATTERN="spec"
// or JEST_FILES_PATTERN="test"
// or JEST_FILES_PATTERN="spec|test"
require('dotenv').config()
module.exports = {
roots: [
'<rootDir>/dist/',
],
testEnvironment: 'node',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
testMatch: [`**/?(*.)+(${process.env.JEST_FILES_PATTERN}).js`]
}
{
...
"scripts": {
...
"build": "rm -rf dist && tsc",
"pretest": "yarn build",
"test": "yarn jest --passWithNoTests"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment