wallabyjs / public

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

"TypeError: this[type] is not a function" in Webstorm #2865

Closed ilyoff closed 2 years ago

ilyoff commented 2 years ago

Issue description or question

Hello. I use create-react-app with typescript and craco package (react-app-rewired alternative). When I try to run wallaby, I'm getting following error on random jsx files:

Failed to instrument src/app/pages/TemplateLibrary/Template/TemplateHistory.jsx
TypeError: this[type] is not a function
    at process.emit (events.js:400:28)
    at emit (internal/child_process.js:910:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

But, if turn on autoDetect and trace flags in my wallaby config, I'm getting different kind of error:

Cannot find module 'react-scripts/scripts/utils/createJestConfig'
Require stack:
- /Users/ilyoff/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/runners/node/bootstrap.js
- /Users/ilyoff/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js

Wallaby config

module.exports = function() {
  const path = require('path');

  process.env.BABEL_ENV = 'test';
  process.env.NODE_ENV = 'test';

  process.env.NODE_PATH += path.delimiter + path.join(__dirname, 'node_modules') + path.delimiter
    + path.join(__dirname, 'node_modules/react-scripts/node_modules');

  require('module')
    .Module
    ._initPaths();

  return {
    files: [
      {
        pattern: 'src/setupTests.ts',
        instrument: false,
      },
      'src/app/**/*.+(ts|tsx|jsx|js|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
      '!src/**/*.spec.ts?(x)',
    ],

    tests: ['src/**/*.spec.ts?(x)'],

    env: {
      type: 'node',
    },

    preprocessors: {
      '**/*.js?(x)': file =>
        require('@babel/core')
          .transform(file.content, {
            sourceMap: true,
            compact: false,
            filename: file.path,
            presets: [require('babel-preset-jest'), 'react-app'],
          }),
    },

    setup: wallaby => {
      const jestConfig = require('react-scripts/scripts/utils/createJestConfig')(p => require.resolve(`react-scripts/${p}`));

      Object.keys(jestConfig.transform || {})
        .forEach(k => ~k.indexOf('^.+\\.(js|jsx') && void delete jestConfig.transform[k]);
      delete jestConfig.testEnvironment;
      wallaby.testFramework.configure(jestConfig);
    },

    testFramework: 'jest',
    // autoDetect: true,
    // trace: true,
  };
};

Wallaby diagnostics report

For "TypeError: this[type] is not a function…"

{
  editorVersion: 'WebStorm 2021.3',
  pluginVersion: '1.0.227',
  editorType: 'IntelliJ',
  osVersion: 'darwin 20.6.0',
  nodeVersion: 'v14.17.5',
  coreVersion: '1.0.1182',
  checksum: 'MDIwOTU0MWNmMzYzMDQ5YjQ0YzVmZGRhMTIzZWNhNTYsMTY2OTI0ODAwMDAwMCww',
  config: {
    files: [
      { pattern: 'src/setupTests.ts', instrument: false, ignore: false, trigger: true, load: true, order: 1 },
      { pattern: 'src/app/**/*.+(ts|tsx|jsx|js|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)', ignore: false, trigger: true, load: true, instrument: true, order: 2 },
      { pattern: 'src/**/*.spec.ts?(x)', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: 'src/**/*.spec.ts?(x).snap', ignore: false, instrument: false, trigger: true, load: true, order: 3 },
      { pattern: 'package.json', ignore: false, instrument: false, trigger: true, load: true, order: 4 }
    ],
    tests: [ { pattern: 'src/**/*.spec.ts?(x)', ignore: false, trigger: true, load: true, test: true, order: 5 } ],
    env: { type: 'node', params: {}, runner: '/usr/local/bin/node', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true },
    preprocessors: { '**/*.js?(x)': [Function: **/*.js?(x)], 'package.json': [Function (anonymous)] },
    testFramework: { version: 'jest@0.4.3', configurator: 'jest@0.4.3', reporter: 'jest@0.4.3', starter: 'jest@0.4.3' },
    diagnostics: {},
    filesWithNoCoverageCalculated: [],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    addModifiedTestFileToExclusiveTestRun: true,
    compilers: { '**/*.?(lit)coffee?(.md)': [Function (anonymous)] },
    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: {},
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    loose: true,
    configCode: 'module.exports = function() {\n' +
      "  const path = require('path');\n" +
      '\n' +
      "  process.env.BABEL_ENV = 'test';\n" +
      "  process.env.NODE_ENV = 'test';\n" +
      "  process.env.REACT_APP_VDI_ENABLED = 'true';\n" +
      "  process.env.REACT_APP_VDI_LOCATION = '/vdi';\n" +
      '\n' +
      "  process.env.NODE_PATH += path.delimiter + path.join(__dirname, 'node_modules') + path.delimiter\n" +
      "    + path.join(__dirname, 'node_modules/react-scripts/node_modules');\n" +
      '\n' +
      "  require('module')\n" +
      '    .Module\n' +
      '    ._initPaths();\n' +
      '\n' +
      '  return {\n' +
      '    files: [\n' +
      '      {\n' +
      "        pattern: 'src/setupTests.ts',\n" +
      '        instrument: false,\n' +
      '      },\n' +
      "      'src/app/**/*.+(ts|tsx|jsx|js|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',\n" +
      "      '!src/**/*.spec.ts?(x)',\n" +
      '    ],\n' +
      '\n' +
      "    tests: ['src/**/*.spec.ts?(x)'],\n" +
      '\n' +
      '    env: {\n' +
      "      type: 'node',\n" +
      '    },\n' +
      '\n' +
      '    preprocessors: {\n' +
      "      '**/*.js?(x)': file =>\n" +
      "        require('@babel/core')\n" +
      '          .transform(file.content, {\n' +
      '            sourceMap: true,\n' +
      '            compact: false,\n' +
      '            filename: file.path,\n' +
      "            presets: [require('babel-preset-jest'), 'react-app'],\n" +
      '          }),\n' +
      '    },\n' +
      '\n' +
      '    setup: wallaby => {\n' +
      "      const jestConfig = require('react-scripts/scripts/utils/createJestConfig')(p => require.resolve(`react-scripts/${p}`));\n" +
      '\n' +
      '      Object.keys(jestConfig.transform || {})\n' +
      "        .forEach(k => ~k.indexOf('^.+\\\\.(js|jsx') && void delete jestConfig.transform[k]);\n" +
      '      delete jestConfig.testEnvironment;\n' +
      '      wallaby.testFramework.configure(jestConfig);\n' +
      '    },\n' +
      '\n' +
      "    testFramework: 'jest',\n" +
      '    // autoDetect: true,\n' +
      '    // trace: true,\n' +
      '  };\n' +
      '};\n'
  },
  packageJSON: {
    dependencies: {
      '@date-io/luxon': '1.x',
      '@formatjs/intl-pluralrules': '^4.1.3',
      '@formatjs/intl-relativetimeformat': '^9.2.3',
      '@formatjs/intl-utils': '^3.8.4',
      '@material-ui/core': '^4.11.3',
      '@material-ui/lab': '^4.0.0-alpha.58',
      '@material-ui/pickers': '^3.3.10',
      '@novnc/novnc': '^1.1.0',
      '@reduxjs/toolkit': '^1.4.0',
      '@sentry/react': '^5.20.1',
      '@types/react-scrollbar': '^0.5.1',
      '@types/react-transition-group': '^4.4.0',
      '@types/uuid': '^3.0.0',
      axios: '^0.21.1',
      'chart.js': '^2.5.0',
      classnames: '^2.2.5',
      'core-js': '^3.6.5',
      debounce: '^1.0.2',
      'font-awesome': '^4.7.0',
      'immutability-helper': '^3.0.2',
      lodash: '^4.17.15',
      luxon: '^2.0.2',
      moment: '^2.18.1',
      netmask: '^1.0.6',
      nprogress: '^0.2.0',
      'prop-types': '^15.7.2',
      'rc-time-picker': '^3.7.3',
      react: '^16.13.1',
      'react-chartjs-2': '^2.0.5',
      'react-copy-to-clipboard': '^5.0.0',
      'react-day-picker': '^7.2.4',
      'react-dnd': '^11.1.3',
      'react-dnd-html5-backend': '^11.1.3',
      'react-dom': '^16.13.1',
      'react-infinite-scroll-component': '^5.1.0',
      'react-infinite-scroller': '^1.0.15',
      'react-intl': '^5.20.10',
      'react-redux': '^7.2.0',
      'react-redux-toastr': '^7.6.5',
      'react-router': '^3.0.0',
      'react-scripts': '4.0.3',
      'react-scrollbar': '^0.5.6',
      'react-select': '^4.3.0',
      'react-select-async-paginate': '^0.6.0',
      'react-slider': '^1.0.8',
      'react-table': '^7.7.0',
      'react-tether': '^1.0.1',
      'react-throttle-render': '^2.0.0',
      'react-transition-group': '^4.4.1',
      'react-window': '^1.8.6',
      reactstrap: '8.4.1',
      redux: '^4.0.5',
      'redux-form': '8.3.5',
      'redux-thunk': '^2.3.0',
      'sockjs-client': '1.1.5',
      switchery: '0.0.2',
      uuid: '^3.0.1'
    },
    devDependencies: {
      '@babel/plugin-proposal-object-rest-spread': '^7.11.0',
      '@babel/plugin-transform-destructuring': '^7.10.4',
      '@craco/craco': '^6.2.0',
      '@react-theming/storybook-addon': '^1.1.1',
      '@storybook/addon-actions': '^6.3.7',
      '@storybook/addon-essentials': '^6.3.7',
      '@storybook/addon-links': '^6.3.7',
      '@storybook/node-logger': '^6.3.7',
      '@storybook/preset-create-react-app': '^3.2.0',
      '@storybook/react': '^6.3.7',
      '@testing-library/cypress': '^7.0.3',
      '@testing-library/jest-dom': '^5.14.1',
      '@testing-library/react': '^12.0.0',
      '@testing-library/react-hooks': '^7.0.2',
      '@testing-library/user-event': '^13.2.1',
      '@types/classnames': '^2.2.10',
      '@types/jest': '^26.0.24',
      '@types/lodash': '^4.14.156',
      '@types/luxon': '^2.0.4',
      '@types/node': '^12.0.0',
      '@types/react': '^16.9.0',
      '@types/react-copy-to-clipboard': '^4.3.0',
      '@types/react-dom': '^16.9.0',
      '@types/react-redux': '7.1.9',
      '@types/react-redux-toastr': '^7.6.0',
      '@types/react-router': '^3.0.23',
      '@types/react-select': '^4.0.15',
      '@types/react-table': '^7.7.0',
      '@types/reactstrap': '8.4.3',
      '@types/redux-form': '^8.3.1',
      '@types/redux-thunk': '^2.1.32',
      '@types/testing-library__cypress': '^5.0.8',
      '@types/webpack-env': '^1.16.0',
      '@typescript-eslint/eslint-plugin': '^4.29.2',
      '@typescript-eslint/parser': '^4.29.2',
      ajv: '^8.6.2',
      'ajv-formats': '^2.1.1',
      'babel-eslint': '^10.1.0',
      'babel-plugin-import': '^1.13.3',
      'copy-webpack-plugin': '^6.0.2',
      'craco-alias': '^3.0.1',
      cypress: '^6.5.0',
      'cypress-wait-until': '^1.7.1',
      'dotenv-cra': '^1.0.0',
      'eslint-config-airbnb': '^18.1.0',
      'eslint-import-resolver-alias': '^1.1.2',
      'eslint-plugin-babel': '^5.3.0',
      'eslint-plugin-compat': '^3.7.0',
      'eslint-plugin-cypress': '^2.11.2',
      'eslint-plugin-import': '^2.21.2',
      'eslint-plugin-jest-dom': '^3.6.5',
      'eslint-plugin-jsx-a11y': '^6.2.3',
      'eslint-plugin-react': '^7.20.0',
      'eslint-plugin-react-hooks': '^4.0.4',
      'eslint-plugin-testing-library': '^3.10.1',
      'eslint-plugin-unicorn': '^20.1.0',
      'eslint-teamcity': '^3.0.1',
      'html-webpack-plugin': '^4.3.0',
      'jest-junit': '^12.0.0',
      'jest-mock-axios': '^4.4.0',
      'jest-teamcity': '^1.9.0',
      'jest-ts-auto-mock': '^2.0.0',
      'mock-socket': '^9.0.3',
      'node-sass': '^4.14.1',
      'react-select-event': '^5.3.0',
      'ts-auto-mock': '^3.3.5',
      'ts-jest': '^26.5.6',
      ttypescript: '^1.5.12',
      typescript: '^4.3.5'
    }
  },
  fs: { numberOfFiles: 1177 },
  debug: [
    '2021-12-03T10:13:49.190Z project Wallaby Node version: v14.17.5\n',
    '2021-12-03T10:13:49.190Z project Wallaby config: <homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/wallaby.js\n',
    '2021-12-03T10:13:49.697Z project File cache: <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/projects/7d5446d96eb111a7\n',
    '2021-12-03T10:13:49.783Z uiService Listening port 51235\n',
    '2021-12-03T10:13:49.794Z project Config file change detected, invalidating local cache\n',
    '2021-12-03T10:13:49.827Z workers Parallelism for initial run: 6, for regular run: 3\n',
    '2021-12-03T10:13:49.827Z workers Starting run worker instance #0\n',
    '2021-12-03T10:13:49.828Z workers Starting run worker instance #1\n',
    '2021-12-03T10:13:49.828Z workers Starting run worker instance #2\n',
    '2021-12-03T10:13:49.828Z workers Starting run worker instance #3\n',
    '2021-12-03T10:13:49.828Z workers Starting run worker instance #4\n',
    '2021-12-03T10:13:49.828Z workers Starting run worker instance #5\n',
    '2021-12-03T10:13:49.828Z workers Web server is listening at 50184\n',
    '2021-12-03T10:13:49.828Z project File cache requires some updates, waiting required files from IDE\n',
    '2021-12-03T10:13:51.801Z workers Started run worker instance (delayed) #0\n',
    '2021-12-03T10:13:51.802Z workers Started run worker instance (delayed) #1\n',
    '2021-12-03T10:13:51.802Z workers Started run worker instance (delayed) #3\n',
    '2021-12-03T10:13:51.802Z workers Started run worker instance (delayed) #4\n',
    '2021-12-03T10:13:51.802Z workers Started run worker instance (delayed) #5\n',
    '2021-12-03T10:13:51.803Z workers Started run worker instance (delayed) #2\n',
    '2021-12-03T10:13:52.391Z project Error: Failed to instrument src/app/pages/TaskScheduler/ScheduleEditDialog/ScheduleEditFormObjects.jsx\n' +
      'TypeError: this[type] is not a function\n' +
      '    at process.emit (events.js:400:28)\n' +
      '    at emit (internal/child_process.js:910:12)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:83:21)\n' +
      '    at Object.formatInstrumentationError (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js:29:29823)\n' +
      '    at <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js:26:3686\n' +
      '    at _rejected (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:864:24)\n' +
      '    at <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:890:30\n' +
      '    at Promise.when (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:1142:31)\n' +
      '    at Promise.promise.promiseDispatch (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:808:41)\n' +
      '    at <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:624:44\n' +
      '    at runSingle (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:137:13)\n' +
      '    at flush (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/node_modules/q/q.js:125:13)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:77:11)\n',
    '2021-12-03T10:13:52.392Z project Stopping process pool\n',
    '2021-12-03T10:13:52.393Z project Changes did not trigger any tests\n'
  ]
}

For "Cannot find module…" error

{
  editorVersion: 'WebStorm 2021.3',
  pluginVersion: '1.0.227',
  editorType: 'IntelliJ',
  osVersion: 'darwin 20.6.0',
  nodeVersion: 'v14.17.5',
  coreVersion: '1.0.1182',
  checksum: 'MDIwOTU0MWNmMzYzMDQ5YjQ0YzVmZGRhMTIzZWNhNTYsMTY2OTI0ODAwMDAwMCww',
  config: {
    files: [
      { pattern: 'src/setupTests.ts', instrument: false, ignore: false, trigger: true, load: true, order: 1 },
      { pattern: 'src/app/**/*.+(ts|tsx|jsx|js|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)', ignore: false, trigger: true, load: true, order: 2 },
      { pattern: 'src/**/*.spec.ts?(x)', ignore: true, trigger: true, load: true }
    ],
    tests: [ { pattern: 'src/**/*.spec.ts?(x)', ignore: false, trigger: true, load: true, test: true, order: 3 } ],
    env: { type: 'node', params: {}, runner: '/usr/local/bin/node', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true },
    preprocessors: { '**/*.js?(x)': [Function: **/*.js?(x)] },
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    trace: true,
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/kq/cz517mqx6n75lw98mntm37hc0000gn/T/jest_dx',
              clearMocks: false,
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend',
              dependencyExtractor: undefined,
              detectLeaks: undefined,
              detectOpenHandles: undefined,
              displayName: undefined,
              errorOnDeprecated: false,
              extraGlobals: [],
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, throwOnModuleCollision: false },
              injectGlobals: true,
              moduleDirectories: [ 'node_modules' ],
              moduleFileExtensions: [
                'web.js',  'js',
                'web.ts',  'ts',
                'web.tsx', 'tsx',
                'json',    'web.jsx',
                'jsx',     'node'
              ],
              moduleLoader: undefined,
              moduleNameMapper: [ [ '^react-native$', 'react-native-web' ], [ '^.+\\.module\\.(css|sass|scss)$', 'identity-obj-proxy' ] ],
              modulePathIgnorePatterns: [],
              modulePaths: [ '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/src' ],
              name: 'd3c3ec95e7d2fe8e657736a341299256',
              prettierPath: 'prettier',
              resetMocks: true,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend',
              roots: [ '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/src' ],
              runner: 'jest-runner',
              setupFiles: [ '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/react-app-polyfill/jsdom.js' ],
              setupFilesAfterEnv: [ '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/src/setupTests.js' ],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/jest-environment-jsdom/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [
                '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
                '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/src/**/*.{spec,test}.{js,jsx,ts,tsx}'
              ],
              testPathIgnorePatterns: [ '/node_modules/' ],
              testRegex: [],
              testRunner: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/jest-circus/runner.js',
              testURL: 'http://localhost',
              timers: 'real',
              transform: [
                [ '^.+\\.(js|jsx|mjs|cjs|ts|tsx)$', '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/react-scripts/config/jest/babelTransform.js', {} ],
                [ '^.+\\.css$', '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/react-scripts/config/jest/cssTransform.js', {} ],
                [ '^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)', '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/react-scripts/config/jest/fileTransform.js', {} ]
              ],
              transformIgnorePatterns: [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$', '^.+\\.module\\.(css|sass|scss)$' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            collectCoverage: false,
            collectCoverageFrom: [ 'src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts' ],
            collectCoverageOnlyFrom: undefined,
            coverageDirectory: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/coverage',
            coverageProvider: 'babel',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: undefined,
            detectLeaks: undefined,
            detectOpenHandles: undefined,
            enabledTestsMap: undefined,
            errorOnDeprecated: false,
            expand: false,
            filter: undefined,
            findRelatedTests: false,
            forceExit: false,
            globalSetup: undefined,
            globalTeardown: undefined,
            json: false,
            lastCommit: false,
            listTests: undefined,
            logHeapUsage: false,
            maxConcurrency: 5,
            maxWorkers: 7,
            noSCM: undefined,
            noStackTrace: false,
            nonFlagArgs: undefined,
            notify: false,
            notifyMode: 'failure-change',
            onlyChanged: false,
            onlyFailures: false,
            outputFile: undefined,
            passWithNoTests: undefined,
            projects: [],
            replname: undefined,
            reporters: undefined,
            rootDir: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend',
            runTestsByPath: false,
            silent: undefined,
            skipFilter: false,
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: [
              { config: {}, path: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/jest-watch-typeahead/filename.js' },
              { config: {}, path: '<homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/node_modules/jest-watch-typeahead/testname.js' }
            ],
            watchman: true
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [ 'src' ],
            watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/' ],
            testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/' ],
            testMatch: [ 'src/**/__tests__/**/*.{js,jsx,ts,tsx}', 'src/**/*.{spec,test}.{js,jsx,ts,tsx}' ],
            testRegex: []
          }
        }
      }
    },
    filesWithCoverageCalculated: [ 'src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts' ],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    micromatch: true,
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    addModifiedTestFileToExclusiveTestRun: true,
    compilers: {},
    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: {},
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    loose: true,
    configCode: 'module.exports = function() {\n' +
      "  const path = require('path');\n" +
      '\n' +
      "  process.env.BABEL_ENV = 'test';\n" +
      "  process.env.NODE_ENV = 'test';\n" +
      "  process.env.REACT_APP_VDI_ENABLED = 'true';\n" +
      "  process.env.REACT_APP_VDI_LOCATION = '/vdi';\n" +
      '\n' +
      "  process.env.NODE_PATH += path.delimiter + path.join(__dirname, 'node_modules') + path.delimiter\n" +
      "    + path.join(__dirname, 'node_modules/react-scripts/node_modules');\n" +
      '\n' +
      "  require('module')\n" +
      '    .Module\n' +
      '    ._initPaths();\n' +
      '\n' +
      '  return {\n' +
      '    files: [\n' +
      '      {\n' +
      "        pattern: 'src/setupTests.ts',\n" +
      '        instrument: false,\n' +
      '      },\n' +
      "      'src/app/**/*.+(ts|tsx|jsx|js|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',\n" +
      "      '!src/**/*.spec.ts?(x)',\n" +
      '    ],\n' +
      '\n' +
      "    tests: ['src/**/*.spec.ts?(x)'],\n" +
      '\n' +
      '    env: {\n' +
      "      type: 'node',\n" +
      '    },\n' +
      '\n' +
      '    preprocessors: {\n' +
      "      '**/*.js?(x)': file =>\n" +
      "        require('@babel/core')\n" +
      '          .transform(file.content, {\n' +
      '            sourceMap: true,\n' +
      '            compact: false,\n' +
      '            filename: file.path,\n' +
      "            presets: [require('babel-preset-jest'), 'react-app'],\n" +
      '          }),\n' +
      '    },\n' +
      '\n' +
      '    setup: wallaby => {\n' +
      "      const jestConfig = require('react-scripts/scripts/utils/createJestConfig')(p => require.resolve(`react-scripts/${p}`));\n" +
      '\n' +
      '      Object.keys(jestConfig.transform || {})\n' +
      "        .forEach(k => ~k.indexOf('^.+\\\\.(js|jsx') && void delete jestConfig.transform[k]);\n" +
      '      delete jestConfig.testEnvironment;\n' +
      '      wallaby.testFramework.configure(jestConfig);\n' +
      '    },\n' +
      '\n' +
      "    testFramework: 'jest',\n" +
      '    autoDetect: true,\n' +
      '    trace: true,\n' +
      '  };\n' +
      '};\n'
  },
  packageJSON: {
    dependencies: {
      '@date-io/luxon': '1.x',
      '@formatjs/intl-pluralrules': '^4.1.3',
      '@formatjs/intl-relativetimeformat': '^9.2.3',
      '@formatjs/intl-utils': '^3.8.4',
      '@material-ui/core': '^4.11.3',
      '@material-ui/lab': '^4.0.0-alpha.58',
      '@material-ui/pickers': '^3.3.10',
      '@novnc/novnc': '^1.1.0',
      '@reduxjs/toolkit': '^1.4.0',
      '@sentry/react': '^5.20.1',
      '@types/react-scrollbar': '^0.5.1',
      '@types/react-transition-group': '^4.4.0',
      '@types/uuid': '^3.0.0',
      axios: '^0.21.1',
      'chart.js': '^2.5.0',
      classnames: '^2.2.5',
      'core-js': '^3.6.5',
      debounce: '^1.0.2',
      'font-awesome': '^4.7.0',
      'immutability-helper': '^3.0.2',
      lodash: '^4.17.15',
      luxon: '^2.0.2',
      moment: '^2.18.1',
      netmask: '^1.0.6',
      nprogress: '^0.2.0',
      'prop-types': '^15.7.2',
      'rc-time-picker': '^3.7.3',
      react: '^16.13.1',
      'react-chartjs-2': '^2.0.5',
      'react-copy-to-clipboard': '^5.0.0',
      'react-day-picker': '^7.2.4',
      'react-dnd': '^11.1.3',
      'react-dnd-html5-backend': '^11.1.3',
      'react-dom': '^16.13.1',
      'react-infinite-scroll-component': '^5.1.0',
      'react-infinite-scroller': '^1.0.15',
      'react-intl': '^5.20.10',
      'react-redux': '^7.2.0',
      'react-redux-toastr': '^7.6.5',
      'react-router': '^3.0.0',
      'react-scripts': '4.0.3',
      'react-scrollbar': '^0.5.6',
      'react-select': '^4.3.0',
      'react-select-async-paginate': '^0.6.0',
      'react-slider': '^1.0.8',
      'react-table': '^7.7.0',
      'react-tether': '^1.0.1',
      'react-throttle-render': '^2.0.0',
      'react-transition-group': '^4.4.1',
      'react-window': '^1.8.6',
      reactstrap: '8.4.1',
      redux: '^4.0.5',
      'redux-form': '8.3.5',
      'redux-thunk': '^2.3.0',
      'sockjs-client': '1.1.5',
      switchery: '0.0.2',
      uuid: '^3.0.1'
    },
    devDependencies: {
      '@babel/plugin-proposal-object-rest-spread': '^7.11.0',
      '@babel/plugin-transform-destructuring': '^7.10.4',
      '@craco/craco': '^6.2.0',
      '@react-theming/storybook-addon': '^1.1.1',
      '@storybook/addon-actions': '^6.3.7',
      '@storybook/addon-essentials': '^6.3.7',
      '@storybook/addon-links': '^6.3.7',
      '@storybook/node-logger': '^6.3.7',
      '@storybook/preset-create-react-app': '^3.2.0',
      '@storybook/react': '^6.3.7',
      '@testing-library/cypress': '^7.0.3',
      '@testing-library/jest-dom': '^5.14.1',
      '@testing-library/react': '^12.0.0',
      '@testing-library/react-hooks': '^7.0.2',
      '@testing-library/user-event': '^13.2.1',
      '@types/classnames': '^2.2.10',
      '@types/jest': '^26.0.24',
      '@types/lodash': '^4.14.156',
      '@types/luxon': '^2.0.4',
      '@types/node': '^12.0.0',
      '@types/react': '^16.9.0',
      '@types/react-copy-to-clipboard': '^4.3.0',
      '@types/react-dom': '^16.9.0',
      '@types/react-redux': '7.1.9',
      '@types/react-redux-toastr': '^7.6.0',
      '@types/react-router': '^3.0.23',
      '@types/react-select': '^4.0.15',
      '@types/react-table': '^7.7.0',
      '@types/reactstrap': '8.4.3',
      '@types/redux-form': '^8.3.1',
      '@types/redux-thunk': '^2.1.32',
      '@types/testing-library__cypress': '^5.0.8',
      '@types/webpack-env': '^1.16.0',
      '@typescript-eslint/eslint-plugin': '^4.29.2',
      '@typescript-eslint/parser': '^4.29.2',
      ajv: '^8.6.2',
      'ajv-formats': '^2.1.1',
      'babel-eslint': '^10.1.0',
      'babel-plugin-import': '^1.13.3',
      'copy-webpack-plugin': '^6.0.2',
      'craco-alias': '^3.0.1',
      cypress: '^6.5.0',
      'cypress-wait-until': '^1.7.1',
      'dotenv-cra': '^1.0.0',
      'eslint-config-airbnb': '^18.1.0',
      'eslint-import-resolver-alias': '^1.1.2',
      'eslint-plugin-babel': '^5.3.0',
      'eslint-plugin-compat': '^3.7.0',
      'eslint-plugin-cypress': '^2.11.2',
      'eslint-plugin-import': '^2.21.2',
      'eslint-plugin-jest-dom': '^3.6.5',
      'eslint-plugin-jsx-a11y': '^6.2.3',
      'eslint-plugin-react': '^7.20.0',
      'eslint-plugin-react-hooks': '^4.0.4',
      'eslint-plugin-testing-library': '^3.10.1',
      'eslint-plugin-unicorn': '^20.1.0',
      'eslint-teamcity': '^3.0.1',
      'html-webpack-plugin': '^4.3.0',
      'jest-junit': '^12.0.0',
      'jest-mock-axios': '^4.4.0',
      'jest-teamcity': '^1.9.0',
      'jest-ts-auto-mock': '^2.0.0',
      'mock-socket': '^9.0.3',
      'node-sass': '^4.14.1',
      'react-select-event': '^5.3.0',
      'ts-auto-mock': '^3.3.5',
      'ts-jest': '^26.5.6',
      ttypescript: '^1.5.12',
      typescript: '^4.3.5'
    }
  },
  fs: { numberOfFiles: 1177 },
  debug: [
    '2021-12-03T10:06:42.699Z angular/cli config Angular CLI not found.\n',
    '2021-12-03T10:06:43.016Z jest/config Detected Jest.\n',
    '2021-12-03T10:06:43.017Z jest/config Configured Jest.\n',
    '2021-12-03T10:06:43.018Z project Wallaby Node version: v14.17.5\n',
    '2021-12-03T10:06:43.018Z project Wallaby config: <homeDir>/Documents/Projects/ASD/ibs/ibs_vms_frontend/wallaby.js\n',
    '2021-12-03T10:06:43.594Z project File cache: <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/projects/7d5446d96eb111a7\n',
    '2021-12-03T10:06:43.692Z uiService Listening port 51235\n',
    '2021-12-03T10:06:43.707Z project Config file change detected, invalidating local cache\n',
    '2021-12-03T10:06:43.813Z workers Parallelism for initial run: 6, for regular run: 3\n',
    '2021-12-03T10:06:43.813Z workers Starting run worker instance #0\n',
    '2021-12-03T10:06:43.813Z workers Starting run worker instance #1\n',
    '2021-12-03T10:06:43.813Z workers Starting run worker instance #2\n',
    '2021-12-03T10:06:43.813Z workers Starting run worker instance #3\n',
    '2021-12-03T10:06:43.813Z workers Starting run worker instance #4\n',
    '2021-12-03T10:06:43.814Z workers Starting run worker instance #5\n',
    '2021-12-03T10:06:43.814Z workers Web server is listening at 64723\n',
    '2021-12-03T10:06:43.814Z project File cache requires some updates, waiting required files from IDE\n',
    '2021-12-03T10:06:44.082Z workers Started run worker instance (delayed) #0\n',
    '2021-12-03T10:06:44.083Z workers Started run worker instance (delayed) #1\n',
    '2021-12-03T10:06:44.084Z workers Started run worker instance (delayed) #2\n',
    '2021-12-03T10:06:44.085Z workers Started run worker instance (delayed) #3\n',
    '2021-12-03T10:06:44.086Z workers Started run worker instance (delayed) #4\n',
    '2021-12-03T10:06:44.088Z project Stopping process pool\n',
    '2021-12-03T10:06:44.089Z project Promoting test run to full run because of test selection changes\n',
    '2021-12-03T10:06:44.089Z project Test run started; run priority: 3\n',
    '2021-12-03T10:06:44.093Z project Running all tests\n',
    '2021-12-03T10:06:44.105Z workers Starting test run, priority: 3\n',
    '2021-12-03T10:06:44.106Z nodeRunner Starting sandbox [worker #0, session #966cf]\n',
    '2021-12-03T10:06:44.106Z nodeRunner Preparing sandbox [worker #0, session #966cf]\n',
    '2021-12-03T10:06:44.106Z nodeRunner Prepared sandbox [worker #0, session #966cf]\n',
    '2021-12-03T10:06:44.107Z workers [worker #0, session #966cf] Running tests in sandbox\n',
    '2021-12-03T10:06:44.118Z workers Started run worker instance (delayed) #5\n',
    "2021-12-03T10:06:44.126Z workers Sandbox (active) [966cf] error: Cannot find module 'react-scripts/scripts/utils/createJestConfig'\n" +
      'Require stack:\n' +
      '- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/runners/node/bootstrap.js\n' +
      '- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js\n',
    '2021-12-03T10:06:44.232Z workers [966cf] Run 0 test(s), skipped 0 test(s)\n',
    '2021-12-03T10:06:44.235Z workers [966cf] Sandbox is responsive, closing it\n',
    "2021-12-03T10:06:44.237Z workers Failed to map the stack to user code, entry message: Cannot find module 'react-scripts/scripts/utils/createJestConfig'\n" +
      'Require stack:\n' +
      '- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/runners/node/bootstrap.js\n' +
      "- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js, stack: Error: Cannot find module 'react-scripts/scripts/utils/createJestConfig'\n" +
      'Require stack:\n' +
      '- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/runners/node/bootstrap.js\n' +
      '- <homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js\n' +
      '    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)\n' +
      '    at Function.Module._load (internal/modules/cjs/loader.js:745:27)\n' +
      '    at Module.require (internal/modules/cjs/loader.js:961:19)\n' +
      '    at Module.n.require (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js:30:1281)\n' +
      '    at Module.n.require (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/server.js:30:1281)\n' +
      '    at require (internal/modules/cjs/helpers.js:92:18)\n' +
      '    at eval (eval at module.exports (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wallaby/runners/node/bootstrap.js:14:44), <anonymous>:2:26)\n' +
      '    at eval (eval at module.exports (<homeDir>/Library/Caches/JetBrains/WebStorm2021.3/wallaby/wall\n',
    '2021-12-03T10:06:44.238Z project Test run finished\n',
    '2021-12-03T10:06:44.238Z project Processed console.log entries\n',
    '2021-12-03T10:06:44.238Z project Processed loading sequences\n',
    '2021-12-03T10:06:44.238Z project Processed executed tests\n',
    '2021-12-03T10:06:44.242Z project Processed code coverage\n',
    '2021-12-03T10:06:45.995Z project Test run result processed and sent to IDE\n'
  ]
}
smcenlly commented 2 years ago

I assume that you are running your tests from your package.json or from the CLI with craco test?

Wallaby doesn't provide direct support for craco which means that you will need to ensure that npx jest runs from the CLI in order for Wallaby to work. I assume that you get the same failures when using npx jest as you get when using Wallaby?

You may need to look at what the craco scripts are doing to create a jest.config.js file that does the same thing in your project root for Wallaby / Jest CLI to use. Please also note that you can override Wallaby's jest automatic configuration to use a different jest configuration file if required (see our docs).

ilyoff commented 2 years ago

@smcenlly Hi, Simon, thank you for your response. I have created jest.config.js file, as mentioned in craco docs, checked npx jest command, and got working tests. But wallaby still not working and I'm getting same errors.

smcenlly commented 2 years ago

Could you please try using this as your wallaby.js configuration file instead?

module.exports = () => {
  return {
    // tell wallaby to use automatic configuration
    autoDetect: true,

    testFramework: {
      // the jest configuration file path (relative to project root)
      configFile: './jest.config.wallaby.js'
    }
  }
};

There shouldn't be anything else that you need to do at this point if everything is working when you using npx jest from the command line.

smcenlly commented 2 years ago

Assuming our last suggestion fixed your problem.

ilyoff commented 2 years ago

@smcenlly sorry for a long time answer. Yes, your suggestion really worked for me, thank you very much! But unfortunately, it works much slower than in video demos. It took about 8 minutes on the first run (about 1500 tests). Maybe, the possible reason is ts-auto-mock and avj packages usage in tests

smcenlly commented 2 years ago

The speed of Wallaby running your test is affected by your tests themselves, and what they're doing. For example, if you are doing something that is cryptographically complex (and expensive in terms of CPU cycles) then Wallaby will take longer to run your test. Similarly, if you are editing code that is common to your entire project (e.g. something infrastructural like Logging) then after that change, Wallaby will need to re-execute many tests, which may take longer than editing code that is only related to a single test.

I recommend using Wallaby's Test Profiler to see what it is your tests are doing and where the time is being taken. This should allow you to optimise your tests (or at the very least, understand why they are taking so long).