const fs = require('fs');
const path = require('path');

const packages = fs
  .readdirSync(path.join(process.cwd(), 'packages'))
  .filter((name) => !['dev-utils'].includes(name));

const docsSrc = '<rootDir>/packages/documentation/src';

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'jsdom',
  roots: packages.map((name) => `<rootDir>/packages/${name}/src`),
  globals: {
    'ts-jest': {
      tsconfig: './tsconfig.test.json',
    },
  },
  setupFilesAfterEnv: ['<rootDir>/testSetup/init.js'],
  transform: {
    '\\.svg$': '<rootDir>/testSetup/inlineSvgTransformer.js',
    '\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
      '<rootDir>/testSetup/fileTransformer.js',
  },
  moduleNameMapper: {
    '\\.scss$': 'identity-obj-proxy',
    '^constants/(.*)$': `${docsSrc}/constants/$1`,
    '^components/(.*)$': `${docsSrc}/components/$1`,
    '^hooks/(.*)$': `${docsSrc}/hooks/$1`,
    '^icons/(.*)$': `${docsSrc}/icons/$1`,
    '^pages/(.*)$': `${docsSrc}/pages/$1`,
    '^utils/(.*)$': `${docsSrc}/utils/$1`,
  },
  collectCoverageFrom: [
    '<rootDir>/packages/*/src/**/*.{ts,tsx}',
    // internal usage and don't matter for the library coverage reports
    '!<rootDir>/packages/{dev-utils,documentation,material-icons,react-md}/src/**/*',
    // these are generated files
    '!<rootDir>/packages/*/src/scssVariables.ts',
    // index.ts files are always `export * from "./fileOrFolder"`
    '!<rootDir>/packages/**/index.ts',
  ],
  watchPlugins: [
    'jest-watch-typeahead/filename',
    'jest-watch-typeahead/testname',
  ],
};

@@ -233,16 +233,557 @@
 /src';%0A%0A
+const isWatchMode = /(-w%7C--watch)(%5Cs?.+)?$/.test(process.argv);%0A%0Alet collectCoverageFrom = %5B%5D;%0Aif (!isWatchMode) %7B%0A  collectCoverageFrom = %5B%0A    '%3CrootDir%3E/packages/*/src/**/*.%7Bts,tsx%7D',%0A    // internal usage and don't matter for the library coverage reports%0A    '!%3CrootDir%3E/packages/%7Bdev-utils,documentation,material-icons,react-md%7D/src/**/*',%0A    // these are generated files%0A    '!%3CrootDir%3E/packages/*/src/scssVariables.ts',%0A    // index.ts files are always %60export * from %22./fileOrFolder%22%60%0A    '!%3CrootDir%3E/packages/**/index.ts',%0A  %5D;%0A%7D%0A%0A
 module.e
@@ -1629,407 +1629,8 @@
 From
-: %5B%0A    '%3CrootDir%3E/packages/*/src/**/*.%7Bts,tsx%7D',%0A    // internal usage and don't matter for the library coverage reports%0A    '!%3CrootDir%3E/packages/%7Bdev-utils,documentation,material-icons,react-md%7D/src/**/*',%0A    // these are generated files%0A    '!%3CrootDir%3E/packages/*/src/scssVariables.ts',%0A    // index.ts files are always %60export * from %22./fileOrFolder%22%60%0A    '!%3CrootDir%3E/packages/**/index.ts',%0A  %5D
 ,%0A  

Update coverage for watch mode