wallabyjs / public

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

How to fix " global is not defined" #3143

Closed SMH110 closed 1 year ago

SMH110 commented 1 year ago

Hi 👋 For some reason I am gettting this error message on all my tests "global is not defined" This happend after updating reactp-scripts to the latest version (5.0.1)

Wallaby diagnostics report

{
  editorVersion: '1.75.0-insider',
  pluginVersion: '1.0.348',
  editorType: 'VSCode',
  osVersion: 'win32 10.0.22000',
  nodeVersion: 'v18.1.0',
  coreVersion: '1.0.1365',
  checksum: 'ZjQ5MzQyMmQwYmVmZDg5NTY3MWVjZTFhODc1MmQ5ZDcsMTY4MzY3NjgwMDAwMCww',
  config: {
    tests: [
      { pattern: 'src/**/*.test.ts?(x)', ignore: false, trigger: true, load: true, test: true, order: 3 },
      { pattern: 'src/**/*.Pact.test.ts', ignore: true, trigger: true, load: true, test: true, file: false }
    ],
    env: { type: 'node', params: {}, runner: 'C:\\Program Files\\nodejs\\node.exe', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true },
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: 'C:\\Users\\x\\AppData\\Local\\Temp\\jest',
              clearMocks: false,
              coveragePathIgnorePatterns: [ '\\\\node_modules\\\\' ],
              cwd: 'C:\\repos\\foo\\baz\\baz\\ClientApp',
              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: [
                '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: [],
              name: '013fb8d85ff0fe508ab93b02b62097a5',
              prettierPath: 'prettier',
              resetMocks: true,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: 'C:\\repos\\foo\\baz\\baz\\ClientApp',
              roots: [ 'C:\\repos\\foo\\baz\\baz\\ClientApp\\src' ],
              runner: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\index.js',
              setupFiles: [ 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\react-scripts\\node_modules\\react-app-polyfill\\jsdom.js' ],
              setupFilesAfterEnv: [ 'C:\\repos\\foo\\baz\\baz\\ClientApp\\src\\setupTests.ts' ],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: undefined,
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-environment-jsdom\\build\\index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [
                'C:/repos/foo/baz/baz/ClientApp/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
                'C:/repos/foo/baz/baz/ClientApp/src/**/*.{spec,test}.{js,jsx,ts,tsx}'
              ],
              testPathIgnorePatterns: [ '\\\\node_modules\\\\' ],
              testRegex: [],
              testRunner: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-circus\\runner.js',
              testURL: 'http://localhost',
              timers: 'real',
              transform: [
                [
                  '^.+\\.(js|jsx|mjs|cjs|ts|tsx)$',
                  'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\react-scripts\\config\\jest\\babelTransform.js',
                  {}
                ],
                [ '^.+\\.css$', 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\react-scripts\\config\\jest\\cssTransform.js', {} ],
                [
                  '^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)',
                  'C:\\repos\\foo\\baz\\baz\\ClientApp\\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: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\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: 31,
            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: 'C:\\repos\\foo\\baz\\baz\\ClientApp',
            runTestsByPath: false,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: undefined,
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\@jest\\test-sequencer\\build\\index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: [
              { config: {}, path: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-watch-typeahead\\filename.js' },
              { config: {}, path: 'C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-watch-typeahead\\testname.js' }
            ],
            watchman: true
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [ 'src' ],
            watchPathIgnorePatterns: [ '\\\\node_modules\\\\', '\\.\\\\dist\\\\|\\.\\\\build\\\\|\\.\\\\coverage\\\\|\\.\\\\git\\\\|\\\\\\..+\\\\', 'C:\\Users\\x\\AppData\\Local\\Temp\\jest', '\\.\\coverage' ],
            testPathIgnorePatterns: [ '\\\\node_modules\\\\', '\\.\\\\dist\\\\|\\.\\\\build\\\\|\\.\\\\coverage\\\\|\\.\\\\git\\\\|\\\\\\..+\\\\', 'C:\\Users\\x\\AppData\\Local\\Temp\\jest', '\\.\\coverage' ],
            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,
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    dot: true,
    files: [
      { pattern: '\\\\node_modules\\\\', regexp: /\\node_modules\\/, ignore: true, trigger: true, load: true, file: true },
      {
        pattern: '\\.\\\\dist\\\\|\\.\\\\build\\\\|\\.\\\\coverage\\\\|\\.\\\\git\\\\|\\\\\\..+\\\\',
        regexp: /\.\\dist\\|\.\\build\\|\.\\coverage\\|\.\\git\\|\\\..+\\/,
        ignore: true,
        trigger: true,
        load: true,
        file: true
      },
      { pattern: 'C:\\Users\\x\\AppData\\Local\\Temp\\jest', regexp: /<homeDir>\AppData\Local\Temp\jest/, ignore: true, trigger: true, load: true, file: true },
      { pattern: '\\.\\coverage', regexp: /\.\coverage/, ignore: true, trigger: true, load: true, file: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: 'src/**', ignore: false, trigger: true, load: true, order: 2 },
      { pattern: 'src/**/*.test.ts?(x)', ignore: true, trigger: true, load: true, file: true }
    ],
    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: {},
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: false,
    configCode: 'module.exports = function () {\r\n' +
      '    var path = require("path");\r\n' +
      '    process.env.BABEL_ENV = "test";\r\n' +
      '    process.env.NODE_ENV = "test";\r\n' +
      '    process.env.NODE_PATH +=\r\n' +
      '        path.delimiter +\r\n' +
      '        path.join(__dirname, "node_modules") +\r\n' +
      '        path.delimiter +\r\n' +
      '        path.join(__dirname, "node_modules/react-scripts/node_modules");\r\n' +
      '    require("module").Module._initPaths();\r\n' +
      '\r\n' +
      '    return {\r\n' +
      '        autoDetect: true,\r\n' +
      '        tests: ["src/**/*.test.ts?(x)", "!src/**/*.Pact.test.ts"],\r\n' +
      '        env: {\r\n' +
      '            type: "jsdom"\r\n' +
      '        }\r\n' +
      '    };\r\n' +
      '};\r\n'
  },
  packageJSON: {
    dependencies: {
      '@emotion/react': '^11.7.1',
      '@emotion/styled': '^11.6.0',
      '@fontsource/barlow': '^4.5.9',
      '@fortawesome/fontawesome-free': '^5.15.3',
      '@mui/icons-material': '^5.3.0',
      '@mui/material': '^5.2.3',
      '@mui/styles': '^5.2.3',
      '@uilab/base-components-react': '^1.0.0-alpha.38',
      '@uilab/community-react-core': '^0.6.0',
      '@uilab/core': '^1.0.0-alpha.21',
      axios: '^0.25.0',
      downshift: '^6.1.5',
      'fast-json-patch': '^3.1.1',
      'follow-redirects': '^1.14.9',
      'fontsource-barlow': '^4.0.0',
      highcharts: '^10.3.2',
      'highcharts-react-official': '^3.1.0',
      immer: '^9.0.17',
      lodash: '^4.17.21',
      moment: '^2.29.4',
      'moment-timezone': '^0.5.40',
      'powerbi-client-react': '^1.3.5',
      'powerbi-models': '^1.12.3',
      'prop-types': 'latest',
      qs: '^6.10.3',
      react: '^17.0.2',
      'react-app-polyfill': '^2.0.0',
      'react-dom': '^17.0.2',
      'react-draggable': '^4.4.5',
      'react-router-dom': '^6.3.0',
      'react-transition-group': '^4.4.1',
      'reflect-metadata': '^0.1.13',
      request: '^2.88.2',
      rxjs: '^7.8.0',
      tsyringe: '^4.7.0',
      uuid: '^9.0.0',
      'windows-iana': '^5.1.0'
    },
    devDependencies: {
      '@applitools/eyes-playwright': '^1.12.1',
      '@pact-foundation/pact': '^9.17.2',
      '@playwright/test': '^1.27.1',
      '@testing-library/jest-dom': '^5.12.0',
      '@testing-library/react': '^11.2.7',
      '@testing-library/react-hooks': '^6.0.0',
      '@testing-library/user-event': '^13.1.9',
      '@types/jest': '^26.0.24',
      '@types/lodash': '^4.14.169',
      '@types/react-transition-group': '^4.4.1',
      '@uilab/scss': '^1.0.0-alpha.29',
      'async-wait-until': '^2.0.12',
      faker: '^5.5.3',
      i: '^0.3.7',
      'jest-junit': '^12.0.0',
      'jest-pact': '^0.9.0',
      'jest-watch-typeahead': '^0.6.5',
      npm: '^9.2.0',
      postcss: '^8.3.6',
      prettier: '^2.3.0',
      'react-scripts': '^5.0.1',
      'react-test-renderer': '^17.0.2',
      sass: '^1.32.13',
      typescript: '^3.9.9'
    }
  },
  fs: { numberOfFiles: 1023 },
  debug: [
    '2023-01-10T13:55:13.701Z config Attempting automatic configuration for angular\n',
    '2023-01-10T13:55:13.707Z angular/cli config Angular CLI not found.\n',
    '2023-01-10T13:55:13.707Z config Finished attempting automatic configuration for angular (6ms)\n',
    '2023-01-10T13:55:13.707Z config Attempting automatic configuration for jest\n',
    '2023-01-10T13:55:14.148Z jest/config Detected Jest.\n',
    '2023-01-10T13:55:14.149Z jest/config Configured Jest.\n',
    '2023-01-10T13:55:14.149Z config Finished attempting automatic configuration for jest (442ms)\n',
    '2023-01-10T13:55:14.151Z project Wallaby Node version: v18.1.0\n',
    '2023-01-10T13:55:14.151Z project Wallaby config: C:\\repos\\foo\\baz\\baz\\ClientApp\\wallaby.js\n',
    '2023-01-10T13:55:14.174Z fs File system starting\n',
    '2023-01-10T13:55:17.410Z fs File system scan has finished by timeout\n',
    '2023-01-10T13:55:17.454Z project File cache: C:\\Users\\x\\.vscode-insiders\\extensions\\wallabyjs.wallaby-vscode-1.0.348\\projects\\696aa05548fe31be\n',
    '2023-01-10T13:55:17.674Z uiService Listening port 51235\n',
    '2023-01-10T13:55:20.727Z project package.json file change detected, invalidating local cache\n',
    '2023-01-10T13:55:32.334Z workers Parallelism for initial run: 30, for regular run: 15\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #0\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #1\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #2\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #3\n',

    '2023-01-10T13:55:32.335Z workers Starting run worker instance #26\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #27\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #28\n',
    '2023-01-10T13:55:32.335Z workers Starting run worker instance #29\n',
    '2023-01-10T13:55:32.337Z workers Web server is listening at 57703\n',
    '2023-01-10T13:55:32.337Z project File cache requires some updates, waiting required files from IDE\n',
    '2023-01-10T13:55:33.208Z workers Started run worker instance (delayed) #0\n',
    '2023-01-10T13:55:33.209Z workers Started run worker instance (delayed) #4\n',

    '2023-01-10T13:55:33.243Z workers Started run worker instance (delayed) #24\n',

    '2023-01-10T13:55:34.248Z workers Started run worker instance (delayed) #27\n',
    '2023-01-10T13:55:38.301Z project Stopping process pool\n',
    '2023-01-10T13:55:38.522Z project Test run started; run priority: 3\n',
    '2023-01-10T13:55:38.527Z project Running all tests\n',
    '2023-01-10T13:55:38.544Z workers Starting test run, priority: 3\n',
    '2023-01-10T13:55:38.544Z workers Distributing tests between 30 workers\n',
    '2023-01-10T13:55:38.550Z workers Running tests in parallel\n',
    '2023-01-10T13:55:38.550Z nodeRunner Starting sandbox [worker #0, session #unror]\n',
    '2023-01-10T13:55:38.551Z nodeRunner Starting sandbox [worker #1, session #snnt7]\n',

    '2023-01-10T13:55:38.554Z nodeRunner Starting sandbox [worker #29, session #qg3ii]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #0, session #unror]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #1, session #snnt7]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #2, session #78eoo]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #3, session #z2msf]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #4, session #bgars]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #5, session #2nuxg]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #6, session #s8de6]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #7, session #63ht1]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #8, session #55wdo]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #9, session #zxfkm]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #10, session #mkqe3]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #11, session #cjzua]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #12, session #6bjod]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #13, session #j9dn4]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #14, session #f3js3]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #15, session #oa7qq]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #16, session #6n1f6]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #17, session #9ml7k]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #18, session #y7dzh]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #19, session #oalgu]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #20, session #nmynv]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #21, session #ndzho]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #22, session #g168k]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #23, session #sn4y9]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #24, session #sikso]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #25, session #g7o1u]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #26, session #3rpuw]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #27, session #bpwiy]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #28, session #vwwki]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Preparing sandbox [worker #29, session #qg3ii]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Prepared sandbox [worker #0, session #unror]\n',
    '2023-01-10T13:55:38.555Z nodeRunner Prepared sandbox [worker #1, session #snnt7]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #2, session #78eoo]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #3, session #z2msf]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #4, session #bgars]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #5, session #2nuxg]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #6, session #s8de6]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #7, session #63ht1]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #8, session #55wdo]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #9, session #zxfkm]\n',
    '2023-01-10T13:55:38.556Z nodeRunner Prepared sandbox [worker #10, session #mkqe3]\n',

    '2023-01-10T13:55:38.584Z workers [worker #8, session #55wdo] Running tests in sandbox\n',
    '2023-01-10T13:55:38.587Z workers [worker #9, session #zxfkm] Running tests in sandbox\n',
    '2023-01-10T13:55:38.590Z workers [worker #10, session #mkqe3] Running tests in sandbox\n',

    '2023-01-10T13:55:38.636Z workers [worker #27, session #bpwiy] Running tests in sandbox\n',
    '2023-01-10T13:55:38.639Z workers [worker #28, session #vwwki] Running tests in sandbox\n',
    '2023-01-10T13:55:38.641Z workers [worker #29, session #qg3ii] Running tests in sandbox\n',
    '2023-01-10T13:55:44.415Z workers Scheduling Jest Test Run (z2msf): 2023-01-10T13:55:40.620Z\n',
    '2023-01-10T13:55:44.458Z workers Sandbox (active) [z2msf] error: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (.\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\node_modules\\jest-message-util\\build\\index.js:22:34)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapterInit.js:16:24)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at jestAdapter (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapter.js:22:13)\n' +
      '    at runTestInternal (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:389:22)\n' +
      '    at runTest (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:475:34)\n',
    '2023-01-10T13:55:44.473Z workers [z2msf] Run 0 test(s), skipped 0 test(s)\n',
    '2023-01-10T13:55:44.866Z workers Scheduling Jest Test Run (9ml7k): 2023-01-10T13:55:40.895Z\n',
    '2023-01-10T13:55:44.943Z workers Sandbox (active) [9ml7k] error: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (.\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\node_modules\\jest-message-util\\build\\index.js:22:34)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapterInit.js:16:24)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at jestAdapter (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapter.js:22:13)\n' +
      '    at runTestInternal (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:389:22)\n' +
      '    at runTest (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:475:34)\n',
    '2023-01-10T13:55:44.964Z workers [9ml7k] Run 0 test(s), skipped 0 test(s)\n',
    '2023-01-10T13:55:45.961Z workers Jest Test Run Complete (z2msf): 2023-01-10T13:55:44.294Z\n',
    '2023-01-10T13:55:46.039Z workers [z2msf] Sandbox is responsive, closing it\n',
    '2023-01-10T13:55:46.041Z workers Failed to map the stack to user code, entry message: global is not defined, stack: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node\n',
    '2023-01-10T13:55:46.065Z workers Jest Test Run Complete (9ml7k): 2023-01-10T13:55:44.504Z\n',
    '2023-01-10T13:55:46.066Z workers [9ml7k] Sandbox is responsive, closing it\n',
    '2023-01-10T13:55:46.067Z workers Failed to map the stack to user code, entry message: global is not defined, stack: 
    '2023-01-10T13:55:50.593Z workers Scheduling Jest Test Run (sn4y9): 2023-01-10T13:55:41.838Z\n',
    '2023-01-10T13:55:50.596Z workers Sandbox (active) [sn4y9] error: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (.\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\node_modules\\jest-message-util\\build\\index.js:22:34)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapterInit.js:16:24)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at jestAdapter (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapter.js:22:13)\n' +
      '    at runTestInternal (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:389:22)\n' +
      '    at runTest (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:475:34)\n',
    '2023-01-10T13:55:50.596Z workers [sn4y9] Run 0 test(s), skipped 0 test(s)\n',
    '2023-01-10T13:55:50.606Z workers Jest Test Run Complete (sn4y9): 2023-01-10T13:55:50.587Z\n',
    '2023-01-10T13:55:50.607Z workers [sn4y9] Sandbox is responsive, closing it\n',
    '2023-01-10T13:55:50.607Z workers Failed to map the stack to user code, entry message: global is not defined, stack: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node\n',
    '2023-01-10T13:55:50.622Z workers Scheduling Jest Test Run (oalgu): 2023-01-10T13:55:41.496Z\n',
    '2023-01-10T13:55:50.626Z workers Sandbox (active) [oalgu] error: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (.\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\node_modules\\jest-message-util\\build\\index.js:22:34)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at .\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:2019:30\n' +
      '    at Object.<anonymous> (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapterInit.js:16:24)\n' +
      '    at Runtime._execModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (.\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at jestAdapter (.\\node_modules\\jest-circus\\build\\legacy-code-todo-rewrite\\jestAdapter.js:22:13)\n' +
      '    at runTestInternal (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:389:22)\n' +
      '    at runTest (.\\node_modules\\jest-cli\\node_modules\\jest-runner\\build\\runTest.js:475:34)\n',
    '2023-01-10T13:55:50.626Z workers [oalgu] Run 0 test(s), skipped 0 test(s)\n',
    '2023-01-10T13:55:50.639Z workers Jest Test Run Complete (oalgu): 2023-01-10T13:55:50.618Z\n',
    '2023-01-10T13:55:50.640Z workers [oalgu] Sandbox is responsive, closing it\n',
    '2023-01-10T13:55:50.640Z workers Failed to map the stack to user code, entry message: global is not defined, stack: ReferenceError: global is not defined\n' +
      '    at Object.<anonymous> (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\graceful-fs\\graceful-fs.js:92:1)\n' +
      '    at Runtime._execModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1646:24)\n' +
      '    at Runtime._loadModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1185:12)\n' +
      '    at Runtime.requireModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1009:12)\n' +
      '    at Runtime.requireInternalModule (C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node_modules\\jest-runtime\\build\\index.js:1049:17)\n' +
      '    at C:\\repos\\foo\\baz\\baz\\ClientApp\\node_modules\\jest-cli\\node\n',

    '2023-01-10T13:58:23.027Z workers Merging parallel test run results\n',
    '2023-01-10T13:58:23.028Z project Test run finished\n',
    '2023-01-10T13:58:23.028Z project Processed console.log entries\n',
    '2023-01-10T13:58:23.028Z project Processed loading sequences\n',
    '2023-01-10T13:58:23.028Z project Processed executed tests\n',
    '2023-01-10T13:58:23.028Z project Processed code coverage\n',
    '2023-01-10T13:58:23.029Z project Test run result processed and sent to IDE\n',
    '2023-01-10T13:58:23.441Z fs File changed: package.json\n',
    '2023-01-10T13:58:23.474Z fs No changes detected for package.json\n',
    '2023-01-10T13:58:23.474Z extended-core File was not changed, but file markers may need to be synced\n'
  ]
}
smcenlly commented 1 year ago

We tried setting up a new project with the same public dependencies that you have and the same Wallaby configuration and everything was working for us.

There are certainly parts of your Wallaby configuration that look incorrect but it should still work for you:

wallaby.js configuration

module.exports = function () {
  var 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 {
      autoDetect: true,
      tests: ["src/**/*.spec.js?(x)", "!src/**/*.Pact.test.ts"],
      env: {
          type: "jsdom"
      }
  };
};

Is there any reason that you're not using automatic configuration? the process.env variables should be set by default and there should be no need for changing the NODE_PATH variable. Also, the env.type: "jsdom" won't do anything in this context; this needs to be set in your jest.config.js.


The only thing I can think of is that perhaps your node_modules has conflicting versions of jest installed. You may try removing node_modules and yarn.lock / package-lock.json and then reinstall to see if that fixes your problem.

Also, please try running npm list jest to ensure a single version of jest is installed:

wallaby-3143@1.0.0 /Users/user/temp/wallaby-3143
├─┬ jest-pact@0.9.4
│ └── jest@27.5.1
├─┬ jest-watch-typeahead@0.6.5
│ └── jest@27.5.1 deduped
└─┬ react-scripts@5.0.1
  ├─┬ jest-watch-typeahead@1.1.0
  │ └── jest@27.5.1 deduped
  └── jest@27.5.1 deduped

If uninstalling/reinstalling your node modules does not help, can you please create a sample repo with steps for installing dependencies. Please make sure that the sample repo only has public dependencies.

SMH110 commented 1 year ago

Thanks for your help. This what I go when I ran npm list jest

├─┬ jest-pact@0.9.0
│ └── jest@26.6.0
├─┬ jest-watch-typeahead@0.6.5
│ └── jest@26.6.0 deduped
└─┬ react-scripts@5.0.1
  ├─┬ jest-watch-typeahead@1.1.0
  │ └── jest@27.5.1 deduped
  └── jest@27.5.1

I think I know now the issue is caused by jest-pact package. And to answer your question why I am not using the automatic configuration is because I have some pact tests which they don't run on my local machine as I am using Windows. You can read more here if you like. so I had to exclude those pact tests