wallabyjs / public

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

TypeScript Jest v29 not functioning properly. #3083

Closed evangeloszotos closed 2 years ago

evangeloszotos commented 2 years ago

Issue description

The green squares are not aligned correctly with the line numbers. The bar with "Debug | View Story | Profile | Focus" is not displayed at the right place, when using "jest" with "ts-jest" on TypeScript test files. It works fine on Javascript files.

Also, the "Copy Value" feature is not functioning properly, wether it does not work at all, or it copies an unexpected value.

I reproduced the issue on jest versions >= 28

See Screenshot: The .js and the .ts files should look the same, but they dont. image

Wallaby diagnostics report

{
  editorVersion: '1.71.2',
  pluginVersion: '1.0.348',
  editorType: 'VSCode',
  osVersion: 'darwin 21.6.0',
  nodeVersion: 'v16.17.0',
  coreVersion: '1.0.1332',
  checksum: 'NmViZWU0NWYwZGRhNDMzZWU1MTE4NzhhMjBjMjMxOTgsMTY3Mjg3NjgwMDAwMCww',
  config: {
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/0b/pdnbwc5d26z_3g2gc5xtlt5w0000gn/T/jest_dx',
              clearMocks: false,
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/Documents/GitHub/starter',
              dependencyExtractor: undefined,
              detectLeaks: false,
              detectOpenHandles: false,
              displayName: undefined,
              errorOnDeprecated: false,
              extensionsToTreatAsEsm: [],
              fakeTimers: { enableGlobally: false },
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false },
              id: 'a48ddfadbeb3c1d47e0501dcb77df1e6',
              injectGlobals: true,
              moduleDirectories: [ 'node_modules', 'src' ],
              moduleFileExtensions: [
                'js',   'mjs',
                'cjs',  'jsx',
                'ts',   'tsx',
                'json', 'node'
              ],
              moduleNameMapper: [],
              modulePathIgnorePatterns: [],
              modulePaths: undefined,
              prettierPath: 'prettier',
              resetMocks: false,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: '<homeDir>/Documents/GitHub/starter',
              roots: [ '<homeDir>/Documents/GitHub/starter' ],
              runner: '<homeDir>/Documents/GitHub/starter/node_modules/jest-runner/build/index.js',
              runtime: undefined,
              sandboxInjectedGlobals: [],
              setupFiles: [],
              setupFilesAfterEnv: [],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: { escapeString: false, printBasicPrototype: false },
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/Documents/GitHub/starter/node_modules/jest-environment-node/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ],
              testPathIgnorePatterns: [
                '<homeDir>/Documents/GitHub/starter/node_modules/',
                '<homeDir>/Documents/GitHub/starter/dist/',
                '<homeDir>/Documents/GitHub/starter/src/__tests__/fixtures/'
              ],
              testRegex: [],
              testRunner: '<homeDir>/Documents/GitHub/starter/node_modules/jest-circus/runner.js',
              transform: [ [ '^.+\\.tsx?$', '<homeDir>/Documents/GitHub/starter/node_modules/ts-jest/dist/index.js', {} ] ],
              transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            ci: false,
            collectCoverage: true,
            collectCoverageFrom: [ 'src/**/*.ts', 'src/**/*.tsx', '**/test/**/*.tsx', '!**/*.d.ts' ],
            coverageDirectory: '<homeDir>/Documents/GitHub/starter/coverage',
            coverageProvider: 'babel',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: undefined,
            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>/Documents/GitHub/starter',
            runTestsByPath: false,
            shard: undefined,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: { escapeString: false, printBasicPrototype: false },
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/Documents/GitHub/starter/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: undefined,
            watchman: true,
            workerIdleMemoryLimit: undefined
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [],
            watchPathIgnorePatterns: [
              '/node_modules/',
              '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
              '/private/var/folders/0b/pdnbwc5d26z_3g2gc5xtlt5w0000gn/T/jest_dx',
              '\\./node_modules/',
              '\\./dist/',
              '\\./src/__tests__/fixtures/',
              '\\./coverage'
            ],
            testPathIgnorePatterns: [
              '/node_modules/',
              '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
              '/private/var/folders/0b/pdnbwc5d26z_3g2gc5xtlt5w0000gn/T/jest_dx',
              '\\./node_modules/',
              '\\./dist/',
              '\\./src/__tests__/fixtures/',
              '\\./coverage'
            ],
            testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ],
            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: [ 'src/**/*.ts', 'src/**/*.tsx', '**/test/**/*.tsx', '!**/*.d.ts' ],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    dot: true,
    files: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, file: true, test: true },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      {
        pattern: '/private/var/folders/0b/pdnbwc5d26z_3g2gc5xtlt5w0000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/0b\/pdnbwc5d26z_3g2gc5xtlt5w0000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      { pattern: '\\./node_modules/', regexp: /\.\/node_modules\//, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '\\./dist/', regexp: /\.\/dist\//, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '\\./src/__tests__/fixtures/', regexp: /\.\/src\/__tests__\/fixtures\//, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: '**/__tests__/**/*.[jt]s?(x)', ignore: true, trigger: true, load: true, file: true },
      { pattern: '**/?(*.)+(spec|test).[tj]s?(x)', ignore: true, trigger: true, load: true, file: true }
    ],
    tests: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, test: true, file: false },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      {
        pattern: '/private/var/folders/0b/pdnbwc5d26z_3g2gc5xtlt5w0000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/0b\/pdnbwc5d26z_3g2gc5xtlt5w0000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      { pattern: '\\./node_modules/', regexp: /\.\/node_modules\//, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '\\./dist/', regexp: /\.\/dist\//, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '\\./src/__tests__/fixtures/', regexp: /\.\/src\/__tests__\/fixtures\//, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/__tests__/**/*.[jt]s?(x)', ignore: false, trigger: true, load: true, test: true, order: 2 },
      { pattern: '**/?(*.)+(spec|test).[tj]s?(x)', ignore: false, trigger: true, load: true, test: true, order: 3 }
    ],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    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: false,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: {
      type: 'node',
      params: {},
      runner: '<homeDir>/.nvm/versions/node/v16.17.0/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#410797618'
  },
  packageJSON: {
    dependencies: {},
    devDependencies: {
      '@types/jest': '^29.0.3',
      '@typescript-eslint/eslint-plugin': '^4.18.0',
      '@typescript-eslint/parser': '^4.18.0',
      eslint: '^7.22.0',
      jest: '^29.0.3',
      nodemon: '^2.0.1',
      prettier: '^2.2.1',
      'symlink-dir': '^4.1.0',
      'ts-jest': '^29.0.2',
      'ts-node': '^9.1.1',
      typescript: '^4.8.3'
    }
  },
  fs: { numberOfFiles: 13 },
  debug: [
    '2022-09-26T20:35:11.490Z config Attempting automatic configuration for angular\n',
    '2022-09-26T20:35:11.491Z angular/cli config Angular CLI not found.\n',
    '2022-09-26T20:35:11.491Z config Finished attempting automatic configuration for angular (1ms)\n',
    '2022-09-26T20:35:11.491Z config Attempting automatic configuration for jest\n',
    '2022-09-26T20:35:11.539Z jest/config Detected Jest.\n',
    '2022-09-26T20:35:11.539Z jest/config Configured Jest.\n',
    '2022-09-26T20:35:11.539Z config Finished attempting automatic configuration for jest (48ms)\n',
    '2022-09-26T20:35:11.540Z project Wallaby Node version: v16.17.0\n',
    '2022-09-26T20:35:11.540Z project Wallaby config: <homeDir>/Documents/GitHub/starter/auto.detect\n',
    '2022-09-26T20:35:11.545Z fs File system starting\n',
    '2022-09-26T20:35:11.559Z fs File system scan completed\n',
    '2022-09-26T20:35:11.563Z project File cache: <homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.348/projects/92e92f31d1ced172\n',
    '2022-09-26T20:35:11.589Z uiService Listening port 51235\n',
    '2022-09-26T20:35:11.592Z workers Parallelism for initial run: 8, for regular run: 4\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #0\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #1\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #2\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #3\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #4\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #5\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #6\n',
    '2022-09-26T20:35:11.592Z workers Starting run worker instance #7\n',
    '2022-09-26T20:35:11.592Z workers Web server is listening at 51911\n',
    '2022-09-26T20:35:11.609Z project Stopping process pool\n',
    '2022-09-26T20:35:11.609Z project File cache is up-to-date, starting full test run\n',
    '2022-09-26T20:35:11.612Z project Test run started; run priority: 3\n',
    '2022-09-26T20:35:11.612Z project Running all tests\n',
    '2022-09-26T20:35:11.614Z workers Starting test run, priority: 3\n',
    '2022-09-26T20:35:11.614Z workers Distributing tests between 8 workers\n',
    '2022-09-26T20:35:11.614Z workers Running tests in parallel\n',
    '2022-09-26T20:35:11.614Z nodeRunner Starting sandbox [worker #0, session #1tcbz]\n',
    '2022-09-26T20:35:11.614Z nodeRunner Starting sandbox [worker #1, session #dqg2h]\n',
    '2022-09-26T20:35:11.614Z nodeRunner Preparing sandbox [worker #0, session #1tcbz]\n',
    '2022-09-26T20:35:11.614Z nodeRunner Preparing sandbox [worker #1, session #dqg2h]\n',
    '2022-09-26T20:35:11.691Z workers Started run worker instance (delayed) #0\n',
    '2022-09-26T20:35:11.691Z nodeRunner Prepared sandbox [worker #0, session #1tcbz]\n',
    '2022-09-26T20:35:11.691Z workers [worker #0, session #1tcbz] Running tests in sandbox\n',
    '2022-09-26T20:35:11.692Z workers Started run worker instance (delayed) #1\n',
    '2022-09-26T20:35:11.692Z nodeRunner Prepared sandbox [worker #1, session #dqg2h]\n',
    '2022-09-26T20:35:11.692Z workers [worker #1, session #dqg2h] Running tests in sandbox\n',
    '2022-09-26T20:35:11.697Z workers Started run worker instance (delayed) #3\n',
    '2022-09-26T20:35:11.698Z workers Started run worker instance (delayed) #5\n',
    '2022-09-26T20:35:11.700Z workers Started run worker instance (delayed) #2\n',
    '2022-09-26T20:35:11.700Z workers Started run worker instance (delayed) #6\n',
    '2022-09-26T20:35:11.701Z workers Started run worker instance (delayed) #7\n',
    '2022-09-26T20:35:11.702Z workers Started run worker instance (delayed) #4\n',
    '2022-09-26T20:35:11.891Z workers Scheduling Jest Test Run (1tcbz): 2022-09-26T20:35:11.777Z\n',
    '2022-09-26T20:35:11.891Z workers [1tcbz] Loaded unknown number of test(s)\n',
    '2022-09-26T20:35:11.892Z workers [1tcbz] Test executed: greet\n',
    '2022-09-26T20:35:11.892Z workers [1tcbz] Test executed: greet\n',
    '2022-09-26T20:35:11.892Z workers [1tcbz] Test executed: greet\n',
    '2022-09-26T20:35:11.892Z workers [1tcbz] Test executed: greet\n',
    '2022-09-26T20:35:11.893Z workers [1tcbz] Run 4 test(s), skipped 0 test(s)\n',
    '2022-09-26T20:35:11.893Z workers Jest Test Run Complete (1tcbz): 2022-09-26T20:35:11.890Z\n',
    '2022-09-26T20:35:11.893Z workers [1tcbz] Sandbox is responsive, closing it\n',
    '2022-09-26T20:35:12.554Z workers Scheduling Jest Test Run (dqg2h): 2022-09-26T20:35:11.777Z\n',
    '2022-09-26T20:35:12.555Z workers [dqg2h] Loaded unknown number of test(s)\n',
    '2022-09-26T20:35:12.555Z workers [dqg2h] Test executed: greet\n',
    '2022-09-26T20:35:12.555Z workers [dqg2h] Test executed: greet\n',
    '2022-09-26T20:35:12.555Z workers [dqg2h] Test executed: greet\n',
    '2022-09-26T20:35:12.556Z workers [dqg2h] Test executed: greet\n',
    '2022-09-26T20:35:12.556Z workers [dqg2h] Run 4 test(s), skipped 0 test(s)\n',
    '2022-09-26T20:35:12.556Z workers Jest Test Run Complete (dqg2h): 2022-09-26T20:35:12.554Z\n',
    '2022-09-26T20:35:12.557Z workers [dqg2h] Sandbox is responsive, closing it\n',
    '2022-09-26T20:35:12.557Z workers Merging parallel test run results\n',
    '2022-09-26T20:35:12.557Z project Test run finished\n',
    '2022-09-26T20:35:12.557Z project Processed console.log entries\n',
    '2022-09-26T20:35:12.557Z project Processed loading sequences\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Test name duplicate: greet\n',
    '2022-09-26T20:35:12.557Z project Processed executed tests\n',
    '2022-09-26T20:35:12.558Z project Processed code coverage\n',
    '2022-09-26T20:35:12.564Z project Test run result processed and sent to IDE\n'
  ]
}
smcenlly commented 2 years ago

Can you please share your tsconfig.json?

evangeloszotos commented 2 years ago

tsconfig.json

{
  "compilerOptions": {
    "jsx": "react",
    "esModuleInterop": true,
    "module": "commonjs",
    "target": "es2017",
    "strict": true,
    "sourceMap": false,
    "declaration": true,
    "resolveJsonModule": true,
    "noImplicitAny": false,
    "allowJs": true,
    "outDir": "./dist"
  },
  "include": ["src/**/*"],
}
smcenlly commented 2 years ago

The reason that the indicators are not working for you is that you have explicitly set "sourceMap": false in your tsconfig.json.

Wallaby (and jest/ts-jest) need this value to be true to provide correct line mappings for errors and code-coverage.

You should be able to omit this setting. By default when compiling with TypeScript, sourceMap is set to false. Internally ts-jest will set sourceMap to true if it is not explicitly set in your tsconfig.json as it is normally required in the context of running tests.