wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Code coverage shows in compiled javascript files, but not in typescript source files #3211

Closed Nutriadmin closed 1 year ago

Nutriadmin commented 1 year ago

Issue description or question

I have a Typescript project where I need to compile my source TS files into JS files within the same directory.

When I run wallaby, the coverage green/red side menu boxes are shown for my compiled JS files, instead of the TS source files. I want coverage to be visible for TS files.

Screenshot 2023-05-09 at 13 22 59 Screenshot 2023-05-09 at 13 23 55

When I run jest --coverage in my terminal, I get coverage shown in my TS files with Istanbul. Seems to work fine outside of wallaby when using plain jest.

Screenshot 2023-05-09 at 13 24 31

Any idea why this is happening? Am I doing something wrong? Couldn't find a reference to this issue in the repo or documentation.

wallaby.js

I've tried automatic configuration, and also with this wallaby.js file:

'use strict';
module.exports = function (w) {
  return {
    files: [
      'components/**/*.ts',
      'controllers/**/*.ts',
      'classes/**/*.ts',
      'routes/**/*.ts',
      'util/**/*.ts',
      'models/**/*.ts',
    ],
    tests: [
      'components/**/*.spec.ts',
      'controllers/**/*.spec.ts',
      'classes/**/*.spec.ts',
      'routes/**/*.spec.ts',
      'util/**/*.spec.ts',
      'models/**/*.spec.ts',
    ],
    trace: true,
    debug: true,
    autoDetect: true,
    compilers: {
      '**/*.ts?(x)': w.compilers.typeScript({ isolatedModules: true }),
    },
    env: {
      type: 'node',
      runner: 'node',
    },
    testFramework: 'ts-jest',
  };
};

Wallaby diagnostics report

Here is my Wallaby Diagnostics report

{
  editorVersion: 'WebStorm 2023.1',
  pluginVersion: '1.0.263',
  editorType: 'IntelliJ',
  osVersion: 'darwin 21.6.0',
  nodeVersion: 'v16.13.1',
  coreVersion: '1.0.1306',
  checksum: 'NTdmMzJjZTkxMjZiODJiMTkzNzE3MzVlNDI1MGRhZDQsMTY1ODk2NjQwMDAwMCww',
  config: {
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/_3/14pm39_d2hldmz3j0wq19dlr0000gn/T/jest_dx',
              clearMocks: true,
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/WebstormProjects/NutriAdmin',
              dependencyExtractor: undefined,
              detectLeaks: false,
              detectOpenHandles: false,
              displayName: undefined,
              errorOnDeprecated: false,
              extensionsToTreatAsEsm: [],
              extraGlobals: [],
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: false, throwOnModuleCollision: false },
              injectGlobals: true,
              moduleDirectories: [ 'node_modules' ],
              moduleFileExtensions: [ 'js', 'jsx', 'ts', 'tsx', 'json', 'node' ],
              moduleLoader: undefined,
              moduleNameMapper: [],
              modulePathIgnorePatterns: [],
              modulePaths: undefined,
              name: '6cc3cb5748bccfea8c31a9b6ec412738',
              prettierPath: 'prettier',
              resetMocks: false,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: '<homeDir>/WebstormProjects/NutriAdmin',
              roots: [ '<homeDir>/WebstormProjects/NutriAdmin' ],
              runner: '<homeDir>/WebstormProjects/NutriAdmin/node_modules/jest-runner/build/index.js',
              setupFiles: [],
              setupFilesAfterEnv: [],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: undefined,
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/WebstormProjects/NutriAdmin/node_modules/jest-environment-node/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [ '<homeDir>/WebstormProjects/NutriAdmin/**/*.spec.ts' ],
              testPathIgnorePatterns: [ '/node_modules/' ],
              testRegex: [],
              testRunner: '<homeDir>/WebstormProjects/NutriAdmin/node_modules/jest-circus/runner.js',
              testURL: 'http://localhost',
              timers: 'real',
              transform: [
                [ '^.+\\.ts?$', '<homeDir>/WebstormProjects/NutriAdmin/node_modules/ts-jest/dist/index.js', {} ],
                [ '^.+\\.tsx?$', '<homeDir>/WebstormProjects/NutriAdmin/node_modules/ts-jest/dist/index.js', {} ]
              ],
              transformIgnorePatterns: [ '<homeDir>/WebstormProjects/NutriAdmin/node_modules/' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            collectCoverage: false,
            collectCoverageFrom: [],
            collectCoverageOnlyFrom: undefined,
            coverageDirectory: '<homeDir>/WebstormProjects/NutriAdmin/coverage',
            coverageProvider: 'babel',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: { global: { branches: 100, functions: 100, lines: 100, statements: 100 } },
            detectLeaks: false,
            detectOpenHandles: false,
            errorOnDeprecated: false,
            expand: false,
            filter: undefined,
            findRelatedTests: false,
            forceExit: false,
            globalSetup: undefined,
            globalTeardown: undefined,
            json: false,
            lastCommit: false,
            listTests: false,
            logHeapUsage: false,
            maxConcurrency: 5,
            maxWorkers: 9,
            noSCM: undefined,
            noStackTrace: false,
            nonFlagArgs: undefined,
            notify: false,
            notifyMode: 'failure-change',
            onlyChanged: false,
            onlyFailures: false,
            outputFile: undefined,
            passWithNoTests: false,
            projects: [],
            replname: undefined,
            reporters: undefined,
            rootDir: '<homeDir>/WebstormProjects/NutriAdmin',
            runTestsByPath: false,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: undefined,
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/WebstormProjects/NutriAdmin/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: undefined,
            watchman: true
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [],
            watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/_3/14pm39_d2hldmz3j0wq19dlr0000gn/T/jest_dx', '\\./coverage' ],
            testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/_3/14pm39_d2hldmz3j0wq19dlr0000gn/T/jest_dx', '\\./coverage' ],
            testMatch: [ '**/*.spec.ts' ],
            testRegex: []
          }
        }
      }
    },
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    filesWithCoverageCalculated: [],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    micromatch: true,
    files: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true },
      { pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//, ignore: true, trigger: true, load: true },
      {
        pattern: '/private/var/folders/_3/14pm39_d2hldmz3j0wq19dlr0000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/_3\/14pm39_d2hldmz3j0wq19dlr0000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: '**/*.spec.ts', ignore: true, trigger: true, load: true }
    ],
    tests: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, test: true },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        test: true
      },
      {
        pattern: '/private/var/folders/_3/14pm39_d2hldmz3j0wq19dlr0000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/_3\/14pm39_d2hldmz3j0wq19dlr0000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true,
        test: true
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, test: true },
      { pattern: '**/*.spec.ts', ignore: false, trigger: true, load: true, test: true, order: 2 }
    ],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    smartStart: [
      { test: true, source: false, path: 'components/stripe/customer/id/getCustomerId.spec.ts', startMode: 'always' },
      { test: true, source: false, pattern: '**/*', startMode: 'open' },
      { test: false, source: true, pattern: '**/*', startMode: 'edit' }
    ],
    logLimits: { inline: { depth: 5, elements: 5000 }, values: { default: { stringLength: 200 }, autoExpand: { elements: 5000, stringLength: 8192, depth: 10 } } },
    preprocessors: {},
    maxConsoleMessagesPerTest: 100,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    workers: { initial: 0, regular: 0, recycle: false },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: true,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: {
      type: 'node',
      params: {},
      runner: '<homeDir>/.nvm/versions/node/v16.13.1/bin/node',
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    loose: true,
    configCode: 'auto.detect#2102375755',
    testLocations: [ 'components/stripe/customer/id/getCustomerId.spec.ts' ]
  },
  packageJSON: {
    dependencies: {
      '@azure/identity': '^3.1.1',
      '@azure/msal-node': '^1.14.0',
      '@azure/storage-blob': '^12.12.0',
      '@casl/ability': '^6.3.3',
      '@casl/mongoose': '^7.1.2',
      '@fortawesome/fontawesome-svg-core': '1.2.1',
      '@fortawesome/free-solid-svg-icons': '5.1.1',
      '@googleapis/calendar': '^2.0.0',
      '@googleapis/oauth2': '^0.3.1',
      '@microsoft/microsoft-graph-client': '^3.0.4',
      'adal-node': '0.1.28',
      agenda: '4.3.0',
      'amazon-cognito-identity-js': '^5.2.10',
      'angular-mocks': '1.5.11',
      'angular-ui-router': '0.3.2',
      applicationinsights: '^2.3.4',
      async: '^3.2.4',
      'aws-sdk': '2.1165.0',
      axios: '^0.27.2',
      'azure-graph': '3.1.0',
      'azure-keyvault': '3.0.4',
      'azure-storage': '2.10.5',
      'body-parser': '1.18.3',
      cheerio: '1.0.0-rc.12',
      'connect-mongo': '2.0.3',
      'cookie-parser': '1.4.3',
      cors: '^2.8.5',
      csvtojson: '1.1.12',
      'drip-nodejs': '^3.1.1',
      dropbox: '4.0.27',
      express: '4.16.4',
      'express-session': '1.17.2',
      'express-slow-down': '1.3.1',
      generatorics: '1.1.0',
      handlebars: '4.5.3',
      helmet: '3.21.2',
      'isomorphic-fetch': '3.0.0',
      jsonwebtoken: '9.0.0',
      'jwks-rsa': '^2.0.3',
      konfig: '0.2.1',
      log4js: '^1.1.1',
      luxon: '^3.3.0',
      maxmind: '2.11.1',
      'method-override': '2.3.10',
      moment: '2.29.3',
      'moment-timezone': '0.5.3',
      'mongo-dot-notation': '1.2.0',
      mongoose: '^6.9.2',
      'ms-rest-azure': '2.6.2',
      multer: '1.3.0',
      'node-cache': '4.2.0',
      'node-fetch': '^3.3.0',
      nodemailer: '6.7.5',
      npm: '8.1.0',
      openai: '^3.1.0',
      passport: '0.3.2',
      'passport-azure-ad': '4.3.4',
      promise: '7.1.1',
      qrcode: '1.4.4',
      ramda: '0.27.1',
      request: '2.88.0',
      'request-ip': '2.0.2',
      'sanitize-html': '^1.27.5',
      'serve-favicon': '2.4.5',
      speakeasy: '2.0.0',
      streamifier: '0.1.1',
      stripe: '^12.1.1',
      twilio: '3.78.0',
      typescript: '^4.9.4',
      underscore: '^1.13.4',
      uuid: '^9.0.0',
      wkhtmltopdf: '0.3.4'
    },
    devDependencies: {
      '@microsoft/microsoft-graph-types': '^2.25.0',
      '@types/angular': '^1.6.29',
      '@types/angular-resource': '^1.5.12',
      '@types/angular-strap': '^2.2.33',
      '@types/angular-ui-bootstrap': '^0.13.44',
      '@types/angular-ui-notification': '^0.0.4',
      '@types/async': '3.2.4',
      '@types/bootstrap': '^3.3.36',
      '@types/express': '^4.16.1',
      '@types/express-session': '^1.15.2',
      '@types/jest': '27.4.1',
      '@types/jquery': '^3.2.12',
      '@types/luxon': '^3.3.0',
      '@types/node': '16.18.0',
      '@types/ramda': '0.27.44',
      '@types/underscore': '^1.8.1',
      '@typescript-eslint/eslint-plugin': '^5.59.2',
      '@typescript-eslint/parser': '^5.59.2',
      angular: '^1.7.9',
      'angular-ui-router': '^0.3.1',
      'babel-jest': '27.5.1',
      eslint: '^8.39.0',
      'eslint-plugin-filenames': '^1.2.0',
      grunt: '1.0.4',
      'grunt-cdnify': '1.0.2',
      'grunt-contrib-clean': '1.1.0',
      'grunt-contrib-concat': '1.0.1',
      'grunt-contrib-copy': '1.0.0',
      'grunt-contrib-cssmin': '^4.0.0',
      'grunt-contrib-htmlmin': '2.4.0',
      'grunt-contrib-jshint': '^1.0.0',
      'grunt-contrib-uglify': '^1.0.2',
      'grunt-contrib-watch': '^1.1.0',
      'grunt-critical': '1.1.2',
      'grunt-eslint': '^24.0.1',
      'grunt-includes': '1.0.0',
      'grunt-karma': '^2.0.0',
      'grunt-replace': '1.0.1',
      'grunt-run': '^0.8.1',
      'grunt-sass': '3.1.0',
      'grunt-template': '1.0.0',
      'grunt-uncss': '^0.10.1',
      'grunt-usemin': '2.6.2',
      istanbul: '^0.4.5',
      'jasmine-core': '^2.5.0',
      jest: '27.5.1',
      'jit-grunt': '0.10.0',
      jscpd: '^0.6.11',
      jshint: '^2.10.2',
      karma: '^3.1.4',
      'karma-chrome-launcher': '^2.0.0',
      'karma-coverage': '^1.1.2',
      'karma-jasmine': '^1.0.2',
      'karma-phantomjs-launcher': '^1.0.4',
      'karma-spec-reporter': '^0.0.26',
      'load-grunt-config': '0.19.2',
      newman: '^4.5.6',
      'node-libs-browser': '^2.1.0',
      'node-sass': '^7.0.1',
      nyc: '^13.1.0',
      'phantomjs-prebuilt': '^2.1.16',
      prettier: '^2.6.2',
      'ts-jest': '27.1.4'
    }
  },
  fs: { numberOfFiles: 3982 },
  debug: [
    '2023-05-09T12:21:49.724Z angular/cli config Angular CLI not found.\n',
    '2023-05-09T12:21:49.771Z jest/config Detected Jest.\n',
    '2023-05-09T12:21:49.771Z jest/config Configured Jest.\n',
    '2023-05-09T12:21:49.772Z project Wallaby Node version: v16.13.1\n',
    '2023-05-09T12:21:49.772Z project Wallaby config: <homeDir>/WebstormProjects/NutriAdmin/auto.detect\n',
    '2023-05-09T12:21:50.053Z project File cache: <homeDir>/Library/Caches/JetBrains/WebStorm2023.1/wallaby/projects/5b1ea8541a0d61d2\n',
    '2023-05-09T12:21:50.081Z uiService Listening port 51235\n',
    '2023-05-09T12:21:50.146Z workers Parallelism for initial run: 8, for regular run: 4\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #0\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #1\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #2\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #3\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #4\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #5\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #6\n',
    '2023-05-09T12:21:50.146Z workers Starting run worker instance #7\n',
    '2023-05-09T12:21:50.147Z workers Web server is listening at 55472\n',
    '2023-05-09T12:21:50.168Z project Stopping process pool\n',
    '2023-05-09T12:21:50.168Z project File cache is up-to-date, starting full test run\n',
    '2023-05-09T12:21:50.173Z project Test run started; run priority: 3\n',
    '2023-05-09T12:21:50.178Z project Running all tests\n',
    '2023-05-09T12:21:50.204Z workers Starting test run, priority: 3\n',
    '2023-05-09T12:21:50.204Z nodeRunner Starting sandbox [worker #0, session #plgjs]\n',
    '2023-05-09T12:21:50.204Z nodeRunner Preparing sandbox [worker #0, session #plgjs]\n',
    '2023-05-09T12:21:50.245Z workers Started run worker instance (delayed) #0\n',
    '2023-05-09T12:21:50.246Z nodeRunner Prepared sandbox [worker #0, session #plgjs]\n',
    '2023-05-09T12:21:50.246Z workers [worker #0, session #plgjs] Running tests in sandbox\n',
    '2023-05-09T12:21:50.251Z workers Started run worker instance (delayed) #1\n',
    '2023-05-09T12:21:50.253Z workers Started run worker instance (delayed) #4\n',
    '2023-05-09T12:21:50.254Z workers Started run worker instance (delayed) #2\n',
    '2023-05-09T12:21:50.254Z workers Started run worker instance (delayed) #5\n',
    '2023-05-09T12:21:50.254Z workers Started run worker instance (delayed) #3\n',
    '2023-05-09T12:21:50.255Z workers Started run worker instance (delayed) #7\n',
    '2023-05-09T12:21:50.257Z workers Started run worker instance (delayed) #6\n',
    '2023-05-09T12:21:55.425Z workers Scheduling Jest Test Run (plgjs): 2023-05-09T12:21:50.907Z\n',
    '2023-05-09T12:21:55.426Z workers [plgjs] Loaded unknown number of test(s)\n',
    '2023-05-09T12:21:55.426Z workers [plgjs] Test executed: should get user payment customer when no business id\n',
    '2023-05-09T12:21:55.426Z workers [plgjs] Test executed: should call next with error when findById throws\n',
    '2023-05-09T12:21:55.426Z workers [plgjs] Test executed: should return business payment customer when found in the db\n',
    '2023-05-09T12:21:55.427Z workers [plgjs] Test executed: should return business payment customer undefined when no business is found in db\n',
    '2023-05-09T12:21:55.429Z workers [plgjs] Run 4 test(s), skipped 0 test(s)\n',
    '2023-05-09T12:21:55.429Z workers Jest Test Run Complete (plgjs): 2023-05-09T12:21:55.424Z\n',
    '2023-05-09T12:21:55.430Z workers [plgjs] Sandbox is responsive, closing it\n',
    '2023-05-09T12:21:55.430Z project Test run finished\n',
    '2023-05-09T12:21:55.430Z project Processed console.log entries\n',
    '2023-05-09T12:21:55.430Z project Processed loading sequences\n',
    '2023-05-09T12:21:55.431Z project Processed executed tests\n',
    '2023-05-09T12:21:55.436Z project Processed code coverage\n',
    '2023-05-09T12:21:55.470Z project Test run result processed and sent to IDE\n',
    '2023-05-09T12:22:11.628Z fs No metadata for added file found: .git/index\n',
    '2023-05-09T12:22:11.628Z fs File changed: .git/index\n',
    '2023-05-09T12:22:11.628Z fs No metadata for changed file found: .git/index\n',
    '2023-05-09T12:22:11.634Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:11.637Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:11.637Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:11.637Z project Test run finished\n',
    '2023-05-09T12:22:11.637Z project Test run data re-queued\n',
    '2023-05-09T12:22:19.129Z fs File changed in editor: .gitignore\n',
    '2023-05-09T12:22:19.129Z extended-core New file or complex file change\n',
    '2023-05-09T12:22:19.133Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:19.133Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:19.133Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:19.158Z project Test run finished\n',
    '2023-05-09T12:22:19.158Z project Test run data re-queued\n',
    '2023-05-09T12:22:19.394Z fs File changed: .gitignore\n',
    '2023-05-09T12:22:19.394Z fs No metadata for added file found: .idea/workspace.xml\n',
    '2023-05-09T12:22:19.394Z fs File changed: .idea/workspace.xml\n',
    '2023-05-09T12:22:19.394Z fs No metadata for changed file found: .idea/workspace.xml\n',
    '2023-05-09T12:22:19.394Z fs No changes detected for .gitignore\n',
    '2023-05-09T12:22:19.395Z extended-core File was not changed, but file markers may need to be synced\n',
    '2023-05-09T12:22:25.159Z fs File deleted: wallaby.ts\n',
    '2023-05-09T12:22:25.163Z fs File changed: .git/index\n',
    '2023-05-09T12:22:25.163Z fs No metadata for changed file found: .git/index\n',
    '2023-05-09T12:22:25.163Z fs No metadata for added file found: .git/objects/91/9aa60459f08cf15f730493c3d38b88199c5dcf\n',
    '2023-05-09T12:22:25.164Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:25.167Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:25.167Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:25.189Z project Test run finished\n',
    '2023-05-09T12:22:25.189Z project Test run data re-queued\n',
    '2023-05-09T12:22:25.194Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:25.199Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:25.199Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:25.242Z project Test run finished\n',
    '2023-05-09T12:22:25.242Z project Test run data re-queued\n',
    '2023-05-09T12:22:28.805Z fs File changed in editor: wallaby.js\n',
    '2023-05-09T12:22:28.809Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:28.809Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:28.809Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:28.830Z project Test run finished\n',
    '2023-05-09T12:22:28.830Z project Test run data re-queued\n',
    '2023-05-09T12:22:30.159Z fs File changed in editor: wallaby.js\n',
    '2023-05-09T12:22:30.163Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:30.163Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:30.163Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:30.182Z project Test run finished\n',
    '2023-05-09T12:22:30.182Z project Test run data re-queued\n',
    '2023-05-09T12:22:30.656Z fs File changed in editor: wallaby.js\n',
    '2023-05-09T12:22:30.660Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:30.660Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:30.660Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:30.678Z project Test run finished\n',
    '2023-05-09T12:22:30.678Z project Test run data re-queued\n',
    '2023-05-09T12:22:31.298Z fs File changed in editor: wallaby.js\n',
    '2023-05-09T12:22:31.302Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:31.302Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:31.302Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:31.320Z project Test run finished\n',
    '2023-05-09T12:22:31.320Z project Test run data re-queued\n',
    '2023-05-09T12:22:31.837Z fs File changed in editor: wallaby.js\n',
    '2023-05-09T12:22:31.841Z project Test run started; run priority: 2\n',
    '2023-05-09T12:22:31.841Z testTask Test files from affected: 0, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2023-05-09T12:22:31.842Z testTask Running only selected or not excluded tests\n',
    '2023-05-09T12:22:31.860Z project Test run finished\n',
    '2023-05-09T12:22:31.860Z project Test run data re-queued\n',
    '2023-05-09T12:22:32.537Z fs File changed: wallaby.js\n',
    '2023-05-09T12:22:32.537Z fs File changed: .idea/workspace.xml\n',
    '2023-05-09T12:22:32.537Z fs No metadata for changed file found: .idea/workspace.xml\n',
    '2023-05-09T12:22:32.538Z fs No changes detected for wallaby.js\n',
    '2023-05-09T12:22:32.538Z extended-core File was not changed, but file markers may need to be synced\n'
  ]
}
ArtemGovorov commented 1 year ago

No manual Wallaby config is required for your case.

The reason it's working as described is that Jest prefers .js files over .ts files when processing imports, because according to your log the moduleFileExtensions Jest setting's value is [ 'js', 'jsx', 'ts', 'tsx', 'json', 'node' ].

When I run jest --coverage in my terminal, I get coverage shown in my TS files with Istanbul. Seems to work fine outside of wallaby when using plain jest.

We have tried creating a sample project with default ts-jest config and jest --coverage works the same way as in Wallaby (it reports coverage for .js files).

Not sure why it's working differently in in your project, it may be because .js files are created after you run Jest, or you're using some custom Jest config. Hard to tell without having a reproducible repo with all of your configs and build process.

To make Jest pick .ts files over .js files, you may change your <homeDir>/WebstormProjects/NutriAdmin/jest.config.js file and move .js/.jsx extension to the end of the moduleFileExtensions setting:

module.exports = {
   ...
+  moduleFileExtensions: [ 'ts', 'tsx', 'json', 'node', 'js', 'jsx' ],
};

If you prefer not to do it and would like us to investigate and help configure Wallaby/Jest to work the same way as Jest CLI for your project, please create and share a reproducible repo with all of your configs, build process (that creates .js files) and a dummy test importing a dummy .ts file (where Wallaby picks us a .js file sitting next to it instead, while jest --coverage is working as expected).

Nutriadmin commented 1 year ago

Thanks for your quick reply and suggestion.

I've tried adding the moduleFileExtensions property to my jest.config.ts but it still doesn't work. Here is how it looks like at the moment:

export default {
  resetMocks: false,
  clearMocks: true,
  testMatch: ['<rootDir>/**/*.spec.ts'],
  coverageThreshold: {
    global: {
      branches: 100,
      functions: 100,
      lines: 100,
      statements: 100,
    },
  },
  preset: 'ts-jest',
  testEnvironment: 'node',
  moduleFileExtensions: ['ts', 'tsx', 'json', 'node', 'js', 'jsx'],
  transform: {
    '^.+\\.ts?$': 'ts-jest',
  },
  transformIgnorePatterns: ['<rootDir>/node_modules/'],
};

here is also my tsconfig in case it's useful:

{
  "compilerOptions": {
    "resolveJsonModule": true,
    "target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
    "allowJs": false /* Allow javascript files to be compiled. */,
    "strict": true /* Enable all strict type-checking options. */,
    "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
    "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
    "baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
    "typeRoots": [
      "node_modules/@types",
      "types"
    ] /* List of folders to include type definitions from. */,
    "types": [
      "node",
      "jest"
    ] /* Type declaration files to be included in compilation. */,
    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
    "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
    "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
  },
  "exclude": ["index.js", "node_modules", "coverage", "public", "test"]
}

Do you have other suggestions? If not I will produce a sample repo to reproduce as advised. Should I just create a public github project and share the link?

ArtemGovorov commented 1 year ago

If not I will produce a sample repo to reproduce as advised. Should I just create a public github project and share the link?

Yes, please create a sample Github repo and paste the link here.

Nutriadmin commented 1 year ago

I've fixed the problem!

As I was creating the sample Github repo I had to install npm packages. I realised that I was missing ts-node. After adding it to my package.json and reinstalling I now get coverage on my TS files.

I used to have ts-node in my project in the past but I removed it at some point. Perhaps I still had files installed locally on my node_modules folder or something.

Thanks for looking into it, we can close this now.