wallabyjs / public

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

jsdom / testing-library: crypto is not defined #3384

Closed tslocke closed 2 months ago

tslocke commented 2 months ago

I've started testing client side code using @solidjs/testing-library, which uses jsdom.

When I run in Wallaby I get an error: ReferenceError: crypto is not defined. It's from a library I use (Replicache)

There's no error from the command line (vitest)

As far as I understand crypto is available in Node these days. I've tried importing it and assigning to globalThis but it didn't help.

Thanks : )

{
  editorVersion: '1.89.1',
  pluginVersion: '1.0.379',
  editorType: 'VSCode',
  osVersion: 'darwin 23.5.0',
  nodeVersion: 'v18.12.1',
  coreVersion: '1.0.1580',
  checksum: 'MDY4NDhlNTcwYjk4YzYxNTVkNjYyYWI3M2Q2NTk4M2YsMTc0NTc5ODQwMDAwMCww',
  config: {
    resolveGetters: true,
    logLimits: { inline: { depth: 20, elements: 5000 }, values: { default: { stringLength: 3000 }, autoExpand: { stringLength: 8192, elements: 5000, depth: 10 } } },
    runMode: 'onSave',
    diagnostics: {
      vitest: {
        file: {
          config: "import { defineConfig, loadEnv } from 'vite'\n" +
            "import solid from 'vite-plugin-solid'\n" +
            "import tsconfigPaths from 'vite-tsconfig-paths'\n" +
            'import { sentryVitePlugin } from "@sentry/vite-plugin"\n' +
            "import {dirname, resolve} from 'path'\n" +
            '\n' +
            'const dir = dirname(new URL(import.meta.url).pathname)\n' +
            '\n' +
            'export default defineConfig(({mode}) => {\n' +
            '  process.env = {...process.env, ...loadEnv(mode, process.cwd())};\n' +
            '\n' +
            '  return {\n' +
            '    server: {\n' +
            '      port: +(process.env.VITE_PORT ?? 3000)\n' +
            '    },\n' +
            '\n' +
            '    plugins: [\n' +
            '      // nodePolyfills(),\n' +
            '      tsconfigPaths({loose: true}),\n' +
            '      solid(),\n' +
            '      sentryVitePlugin({\n' +
            '        authToken: process.env.SENTRY_AUTH_TOKEN,\n' +
            '        org: "inio",\n' +
            '        project: "inio-front-end",\n' +
            '        telemetry: false,\n' +
            '      }),\n' +
            '    ],\n' +
            '\n' +
            '    define: {\n' +
            "      'process.env.BABEL_TYPES_8_BREAKING': 'true',\n" +
            '    },  \n' +
            '\n' +
            '    build: {\n' +
            "      target: 'esnext',\n" +
            '      polyfillDynamicImport: false,\n' +
            '      minify: false,\n' +
            '      chunkSizeWarningLimit: 600,\n' +
            '      sourcemap: true,\n' +
            '      rollupOptions: {\n' +
            "        input: './src/main.tsx',\n" +
            '        output: {\n' +
            '          assetFileNames: "[name][extname]",\n' +
            '          chunkFileNames: "[name].js",\n' +
            '          entryFileNames: "[name].js",\n' +
            '          manualChunks: () => "main.js"\n' +
            '        }\n' +
            '      }\n' +
            '    },\n' +
            '\n' +
            '    optimizeDeps: {\n' +
            "      esbuildOptions: { target: 'esnext' }\n" +
            '    },\n' +
            '\n' +
            '    test: {\n' +
            "      environment: 'jsdom',\n" +
            '      transformMode: { web: [/\\.[jt]sx?$/] },\n' +
            '      threads: true,\n' +
            '      isolate: true,\n' +
            '      globals: true\n' +
            '    },\n' +
            '\n' +
            '    resolve: {\n' +
            "      conditions: ['development', 'browser'],\n" +
            '      alias: [\n' +
            "        {find: 'fs', replacement: resolve(dir, 'src/fake-modules.ts')},\n" +
            "        {find: 'path', replacement: resolve(dir, 'src/fake-modules.ts')},\n" +
            "        {find: 'source-map-js', replacement: resolve(dir, 'src/fake-modules.ts')},\n" +
            "        {find: 'url', replacement: resolve(dir, 'src/fake-modules.ts')},\n" +
            '      ]\n' +
            '    },\n' +
            '\n' +
            '\n' +
            '  }\n' +
            '})\n'
        },
        config: {
          config: {
            allowOnly: true,
            isolate: true,
            watch: true,
            globals: true,
            environment: 'jsdom',
            pool: 'threads',
            clearMocks: false,
            restoreMocks: false,
            mockReset: false,
            include: [ '**/*.{test,spec}.?(c|m)[jt]s?(x)' ],
            exclude: [
              '**/node_modules/**',
              '**/dist/**',
              '**/cypress/**',
              '**/.{idea,git,cache,output,temp}/**',
              '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'
            ],
            testTimeout: 5000,
            hookTimeout: 10000,
            teardownTimeout: 10000,
            watchExclude: [ '**/node_modules/**', '**/dist/**' ],
            forceRerunTriggers: [ '**/package.json/**', '**/{vitest,vite}.config.*/**' ],
            update: false,
            reporters: [ [ 'default', {} ] ],
            silent: false,
            hideSkippedTests: false,
            api: { middlewareMode: true },
            ui: false,
            uiBase: '/__vitest__/',
            open: true,
            css: { include: [], modules: { classNameStrategy: 'stable' } },
            coverage: {
              provider: 'v8',
              enabled: false,
              all: true,
              clean: true,
              cleanOnRerun: true,
              reportsDirectory: './coverage',
              exclude: [
                'coverage/**',
                'dist/**',
                '**/[.]**',
                'packages/*/test?(s)/**',
                '**/*.d.ts',
                '**/virtual:*',
                '**/__x00__*',
                '**/\x00*',
                'cypress/**',
                'test?(s)/**',
                'test?(-*).?(c|m)[jt]s?(x)',
                '**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)',
                '**/__tests__/**',
                '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
                '**/vitest.{workspace,projects}.[jt]s?(on)',
                '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'
              ],
              reportOnFailure: false,
              reporter: [ [ 'text', {} ], [ 'html', {} ], [ 'clover', {} ], [ 'json', {} ] ],
              extension: [
                '.js',    '.cjs',
                '.mjs',   '.ts',
                '.mts',   '.cts',
                '.tsx',   '.jsx',
                '.vue',   '.svelte',
                '.marko'
              ],
              allowExternal: false,
              ignoreEmptyLines: false,
              processingConcurrency: 8
            },
            fakeTimers: { loopLimit: 10000, shouldClearNativeTimers: true, toFake: [ 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate', 'Date' ] },
            maxConcurrency: 5,
            dangerouslyIgnoreUnhandledErrors: false,
            typecheck: {
              checker: 'tsc',
              include: [ '**/*.{test,spec}-d.?(c|m)[jt]s?(x)' ],
              exclude: [
                '**/node_modules/**',
                '**/dist/**',
                '**/cypress/**',
                '**/.{idea,git,cache,output,temp}/**',
                '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'
              ],
              enabled: false
            },
            slowTestThreshold: 300,
            disableConsoleIntercept: false,
            transformMode: { web: [ {}, {} ] },
            threads: true,
            server: {
              deps: {
                external: [ {}, {} ],
                inline: [ {}, {}, {}, '@nuxt/test-utils', '@solidjs/router', '@tanstack/solid-table' ],
                moduleDirectories: [ '/node_modules/' ],
                cacheDir: 'node_modules/.vite'
              }
            },
            poolOptions: { threads: { isolate: true }, forks: { isolate: true } },
            config: '<homeDir>/Projects/Inio/inio/web/vite.config.ts',
            defines: {},
            root: '<homeDir>/Projects/Inio/inio/web',
            mode: 'test',
            inspector: { enabled: false, waitForDebugger: false },
            clearScreen: true,
            browser: { fileParallelism: false, enabled: false, headless: false, slowHijackESM: false, isolate: true, api: { middlewareMode: true } },
            fileParallelism: true,
            deps: {
              moduleDirectories: [ '/node_modules/' ],
              optimizer: { ssr: { enabled: true }, web: { enabled: true } },
              web: { transformAssets: true, transformCss: true, transformGlobPattern: [] }
            },
            snapshotOptions: { expand: false, snapshotFormat: {}, updateSnapshot: 'new', snapshotEnvironment: null },
            snapshotSerializers: [],
            poolMatchGlobs: [],
            setupFiles: [],
            globalSetup: [],
            cache: { dir: '<homeDir>/Projects/Inio/inio/web/node_modules/.vite/vitest' },
            sequence: { hooks: 'parallel' },
            environmentMatchGlobs: [],
            testTransformMode: {}
          },
          projects: [
            {
              path: '<homeDir>/Projects/Inio/inio/web',
              config: {
                allowOnly: true,
                isolate: true,
                watch: true,
                globals: true,
                environment: 'jsdom',
                pool: 'threads',
                clearMocks: false,
                restoreMocks: false,
                mockReset: false,
                include: [ '**/*.{test,spec}.?(c|m)[jt]s?(x)' ],
                exclude: [
                  '**/node_modules/**',
                  '**/dist/**',
                  '**/cypress/**',
                  '**/.{idea,git,cache,output,temp}/**',
                  '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'
                ],
                testTimeout: 5000,
                hookTimeout: 10000,
                teardownTimeout: 10000,
                watchExclude: [ '**/node_modules/**', '**/dist/**' ],
                forceRerunTriggers: [ '**/package.json/**', '**/{vitest,vite}.config.*/**' ],
                update: false,
                reporters: [ [ 'default', {} ] ],
                silent: false,
                hideSkippedTests: false,
                api: { middlewareMode: true },
                ui: false,
                uiBase: '/__vitest__/',
                open: true,
                css: { include: [], modules: { classNameStrategy: 'stable' } },
                coverage: {
                  provider: 'v8',
                  enabled: false,
                  all: true,
                  clean: true,
                  cleanOnRerun: true,
                  reportsDirectory: './coverage',
                  exclude: [
                    'coverage/**',
                    'dist/**',
                    '**/[.]**',
                    'packages/*/test?(s)/**',
                    '**/*.d.ts',
                    '**/virtual:*',
                    '**/__x00__*',
                    '**/\x00*',
                    'cypress/**',
                    'test?(s)/**',
                    'test?(-*).?(c|m)[jt]s?(x)',
                    '**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)',
                    '**/__tests__/**',
                    '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
                    '**/vitest.{workspace,projects}.[jt]s?(on)',
                    '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}'
                  ],
                  reportOnFailure: false,
                  reporter: [ [ 'text', {} ], [ 'html', {} ], [ 'clover', {} ], [ 'json', {} ] ],
                  extension: [
                    '.js',    '.cjs',
                    '.mjs',   '.ts',
                    '.mts',   '.cts',
                    '.tsx',   '.jsx',
                    '.vue',   '.svelte',
                    '.marko'
                  ],
                  allowExternal: false,
                  ignoreEmptyLines: false,
                  processingConcurrency: 8
                },
                fakeTimers: { loopLimit: 10000, shouldClearNativeTimers: true, toFake: [ 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate', 'Date' ] },
                maxConcurrency: 5,
                dangerouslyIgnoreUnhandledErrors: false,
                typecheck: {
                  checker: 'tsc',
                  include: [ '**/*.{test,spec}-d.?(c|m)[jt]s?(x)' ],
                  exclude: [
                    '**/node_modules/**',
                    '**/dist/**',
                    '**/cypress/**',
                    '**/.{idea,git,cache,output,temp}/**',
                    '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'
                  ],
                  enabled: false
                },
                slowTestThreshold: 300,
                disableConsoleIntercept: false,
                transformMode: { web: [ {}, {} ] },
                threads: true,
                server: {
                  deps: {
                    external: [ {}, {} ],
                    inline: [ {}, {}, {}, '@nuxt/test-utils', '@solidjs/router', '@tanstack/solid-table' ],
                    moduleDirectories: [ '/node_modules/' ],
                    cacheDir: 'node_modules/.vite'
                  }
                },
                poolOptions: { threads: { isolate: true }, forks: { isolate: true } },
                config: '<homeDir>/Projects/Inio/inio/web/vite.config.ts',
                defines: {},
                root: '<homeDir>/Projects/Inio/inio/web',
                mode: 'test',
                inspector: { enabled: false, waitForDebugger: false },
                clearScreen: true,
                browser: { fileParallelism: false, enabled: false, headless: false, slowHijackESM: false, isolate: true, api: { middlewareMode: true } },
                fileParallelism: true,
                deps: {
                  moduleDirectories: [ '/node_modules/' ],
                  optimizer: { ssr: { enabled: true }, web: { enabled: true } },
                  web: { transformAssets: true, transformCss: true, transformGlobPattern: [] }
                },
                snapshotOptions: { expand: false, snapshotFormat: {}, updateSnapshot: 'new', snapshotEnvironment: null },
                snapshotSerializers: [],
                poolMatchGlobs: [],
                setupFiles: [],
                globalSetup: [],
                cache: { dir: '<homeDir>/Projects/Inio/inio/web/node_modules/.vite/vitest' },
                sequence: { hooks: 'parallel' },
                environmentMatchGlobs: [],
                testTransformMode: {}
              }
            }
          ],
          package: {
            version: '1.6.0',
            urls: { hooks: 'file://<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/runners/node/hooks.mjs' },
            paths: { root: '<homeDir>/Projects/Inio/inio/web/node_modules/vitest', dist: '<homeDir>/Projects/Inio/inio/web/node_modules/vitest/dist' }
          }
        }
      }
    },
    testFramework: { version: 'vitest@0.14.0', configurator: 'vitest@0.14.0', reporter: 'vitest@0.14.0', starter: 'vitest@0.14.0', autoDetected: true },
    preserveComments: false,
    extractComments: true,
    files: [
      { pattern: '**/*.{test,spec}.?(c|m)[jt]s?(x)', ignore: true, trigger: true, load: true, file: true },
      { pattern: '**/node_modules/**', ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/dist/**', ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/cypress/**', ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/.{idea,git,cache,output,temp}/**', ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*', ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/*.timestamp-*', ignore: true, trigger: true, load: true, file: true },
      { pattern: '**/*.*', ignore: false, trigger: true, load: true, order: 1 }
    ],
    tests: [
      { pattern: '**/node_modules/**', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/dist/**', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/cypress/**', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/.{idea,git,cache,output,temp}/**', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/*.{test,spec}.?(c|m)[jt]s?(x)', ignore: false, trigger: true, load: true, test: true, order: 2 }
    ],
    workers: { initial: 1, regular: 1, recycle: false },
    dot: true,
    captureConsoleLog: true,
    filesWithNoCoverageCalculated: [],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    preprocessors: {},
    maxConsoleMessagesPerTest: 100,
    maxTraceSteps: 999999,
    maxTraceStepsForWatchExpressionPrefetch: 0,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore|c8 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: '--experimental-loader=file://<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/runners/node/hooks.mjs' },
      runner: '<homeDir>/.fnm/node-versions/v18.12.1/installation/bin/node',
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: true,
    symlinkNodeModules: true,
    configCode: 'export default {\n' +
      '  resolveGetters: true,\n' +
      '\n' +
      '  logLimits: {\n' +
      '    inline: {\n' +
      '      depth: 20,\n' +
      '    },\n' +
      '    values: {\n' +
      '      default: {\n' +
      '        stringLength: 3000,\n' +
      '      },\n' +
      '      autoExpand: {\n' +
      '        stringLength: 8192,\n' +
      '        elements: 5000,\n' +
      '        depth: 10,\n' +
      '      }\n' +
      '    },\n' +
      '  },\n' +
      '\n' +
      '  runMode: "onSave",\n' +
      '} \n'
  },
  packageJSON: {
    dependencies: {
      '@babel/standalone': '^7.24.5',
      '@codemirror/lang-css': '^6.2.1',
      '@codemirror/lang-javascript': '^6.2.1',
      '@codemirror/theme-one-dark': '^6.1.2',
      '@floating-ui/dom': '^1.2.6',
      '@mhsdesign/jit-browser-tailwindcss': '^0.4.0',
      '@sentry/browser': '^7',
      '@sentry/tracing': '^7',
      '@sentry/vite-plugin': '^2.16.0',
      '@solid-primitives/scheduled': '^1.4',
      '@solidjs/router': '^0.14',
      '@tanstack/solid-table': '^8.19',
      assert: '^2.1.0',
      axios: '^1.3.6',
      'babel-preset-solid': '^1.8',
      'base64-js': '^1.5.1',
      'browser-util-inspect': '^0.2.0',
      codemirror: '^6.0.1',
      'escape-html': '^1.0.3',
      'fast-array-diff': '^1.1.0',
      'fractional-indexing': '^3.2.0',
      fuzzy: '^0.1',
      'hotkeys-js': '^3.10.2',
      inflection: '^2.0.1',
      minisearch: '^6.0.1',
      mitt: '^3.0',
      nanoid: '^4.0.2',
      'next-tick': '^1.1',
      'prosemirror-commands': '^1.5',
      'prosemirror-dropcursor': '^1.8',
      'prosemirror-history': '^1.3',
      'prosemirror-inputrules': '^1.4',
      'prosemirror-keymap': '^1.2',
      'prosemirror-model': '^1.19',
      'prosemirror-state': '^1.4',
      'prosemirror-transform': '^1.8',
      'prosemirror-view': '^1.33',
      'pusher-js': '^8.0.2',
      ramda: '^0.29.0',
      replicache: '^12.2.1',
      'scroll-into-view-if-needed': '^3.0.10',
      snabbdom: '^3.6.2',
      'solid-boundaries': '^2.1.0',
      'solid-js': '^1.8',
      xregexp: '^5.1.1'
    },
    devDependencies: {
      '@babel/parser': '^7.24.5',
      '@babel/types': '^7.24.5',
      '@lezer/generator': '^1.5.1',
      '@solidjs/testing-library': '^0.8',
      '@tailwindcss/forms': '^0.5',
      '@tailwindcss/typography': '^0.5',
      '@types/babel__standalone': '^7.1.7',
      '@types/escape-html': '^1.0.2',
      '@types/inflection': '^1.13.0',
      '@types/json-pointer': '^1.0.31',
      '@types/next-tick': '^1.0.0',
      '@types/node': '^18.15.13',
      '@types/object-inspect': '^1.8.1',
      '@types/ramda': '^0.29.0',
      autoprefixer: '^10.4',
      'fake-indexeddb': '^6.0.0',
      jsdom: '^24.1.0',
      'json-beautify': '^1.1',
      'json-pointer': '^0.6.2',
      'object-inspect': '^1.12.3',
      'patch-package': '^8.0.0',
      postcss: '^8.4.14',
      'postcss-import': '^16.1.0',
      'postinstall-postinstall': '^2.1.0',
      'solid-devtools': '^0.30',
      'ts-unused-exports': '^9.0.4',
      typescript: '^5.4',
      vite: '^5.2',
      'vite-plugin-solid': '^2.10',
      'vite-tsconfig-paths': '^4.3',
      vitest: '^1.6'
    }
  },
  fs: { numberOfFiles: 349 },
  debug: [
    '2024-07-17T08:37:32.085Z project waiting for initial run signal\n',
    '2024-07-17T08:37:32.089Z model Initialization Completed: 135ms\n',
    '2024-07-17T08:37:32.101Z config Attempting automatic configuration for vitest\n',
    '2024-07-17T08:37:32.103Z vitest/config Detected Vitest (1.6.0).\n',
    '2024-07-17T08:37:33.137Z config Finished attempting automatic configuration for vitest (1036ms)\n',
    '2024-07-17T08:37:33.138Z project Wallaby Node version: v18.12.1\n',
    '2024-07-17T08:37:33.138Z project Wallaby config: <homeDir>/Projects/Inio/inio/web/wallaby.js\n',
    '2024-07-17T08:37:33.166Z fs File system starting\n',
    '2024-07-17T08:37:33.198Z fs File system scan completed\n',
    '2024-07-17T08:37:33.203Z project File cache: <homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/projects/b6c1129a40e7d527\n',
    '2024-07-17T08:37:33.250Z ui.service.legacy Listening port 51235\n',
    '2024-07-17T08:37:33.264Z workers Parallelism for initial run: 1, for regular run: 1\n',
    '2024-07-17T08:37:33.264Z workers Starting run worker instance #0\n',
    '2024-07-17T08:37:33.265Z workers Web server is listening at 56968\n',
    '2024-07-17T08:37:33.268Z project File cache requires some updates, waiting required files from IDE\n',
    '2024-07-17T08:37:33.273Z fs File changed in editor: src/store/system-blocks.ts\n',
    '2024-07-17T08:37:33.332Z project Stopping process pool\n',
    '2024-07-17T08:37:33.334Z project Test run started; run priority: 3\n',
    '2024-07-17T08:37:33.335Z project Running all tests\n',
    '2024-07-17T08:37:33.338Z workers Starting test run, priority: 3\n',
    '2024-07-17T08:37:33.338Z nodeRunner Starting sandbox [worker #0, session #ybrag]\n',
    '2024-07-17T08:37:33.339Z nodeRunner Preparing sandbox [worker #0, session #ybrag]\n',
    '2024-07-17T08:37:33.384Z workers Started run worker instance (delayed) #0\n',
    '2024-07-17T08:37:33.384Z nodeRunner Prepared sandbox [worker #0, session #ybrag]\n',
    '2024-07-17T08:37:33.384Z workers [worker #0, session #ybrag] Running tests in sandbox\n',
    '2024-07-17T08:37:33.695Z fs No metadata for added file found: node_modules/.vite/vitest/results.json\n',
    '2024-07-17T08:37:33.795Z fs No metadata for added file found: vite.config.ts.timestamp-1721205453734-f0227373cf811.mjs\n',
    '2024-07-17T08:37:33.897Z fs No metadata for deleted file found: vite.config.ts.timestamp-1721205453734-f0227373cf811.mjs\n',
    "2024-07-17T08:37:34.030Z workers 'Scheduling Vitest Run (ybrag): 2024-07-17T08:37:34.030Z'\n",
    '2024-07-17T08:37:40.517Z workers [ybrag.1] Loaded unknown number of test(s)\n',
    '2024-07-17T08:37:40.621Z workers [ybrag.1] Test executed: wip\n',
    '2024-07-17T08:37:40.635Z workers Sandbox (active) [ybrag] error: ReferenceError: crypto is not defined\n' +
      '    at si (file://<rootDir>/node_modules/replicache/out/replicache.js:1:13637)\n' +
      '    at file://<rootDir>/node_modules/replicache/out/replicache.js:1:14047\n' +
      '    at file://<rootDir>/node_modules/replicache/out/replicache.js:1:58049\n' +
      '    at Oe (file://<rootDir>/node_modules/replicache/out/replicache.js:1:49451)\n' +
      '    at dr.dn (file://<rootDir>/node_modules/replicache/out/replicache.js:7:6958)\n',
    "2024-07-17T08:37:40.687Z workers 'Vitest Run Complete (ybrag): 2024-07-17T08:37:40.686Z'\n",
    '2024-07-17T08:37:40.690Z workers [ybrag] Run 1 test(s), skipped 0 test(s)\n',
    '2024-07-17T08:37:40.690Z workers [ybrag] Sandbox is responsive, closing it\n',
    '2024-07-17T08:37:40.691Z workers Failed to map the stack to user code, entry message: ReferenceError: crypto is not defined, stack: ReferenceError: crypto is not defined\n' +
      '    at si (file://<homeDir>/Projects/Inio/inio/web/node_modules/replicache/out/replicache.js:1:13637)\n' +
      '    at file://<homeDir>/Projects/Inio/inio/web/node_modules/replicache/out/replicache.js:1:14047\n' +
      '    at file://<homeDir>/Projects/Inio/inio/web/node_modules/replicache/out/replicache.js:1:58049\n' +
      '    at Oe (file://<homeDir>/Projects/Inio/inio/web/node_modules/replicache/out/replicache.js:1:49451)\n' +
      '    at dr.dn (file://<homeDir>/Projects/Inio/inio/web/node_modules/replicache/out/replicache.js:7:6958)\n',
    '2024-07-17T08:37:40.695Z project Test run finished\n',
    '2024-07-17T08:37:40.695Z project Processed console.log entries\n',
    '2024-07-17T08:37:40.696Z project Processed loading sequences\n',
    '2024-07-17T08:37:40.696Z project Processed executed tests\n',
    '2024-07-17T08:37:40.713Z project Processed code coverage\n',
    '2024-07-17T08:37:40.761Z project Test run result processed and sent to IDE\n',
    '2024-07-17T08:37:40.764Z fs File changed: node_modules/.vite/vitest/results.json\n',
    '2024-07-17T08:37:40.764Z fs No metadata for changed file found: node_modules/.vite/vitest/results.json\n'
  ]
}
ArtemGovorov commented 2 months ago

Hi, we have tried to reproduce the issue, but everything seems to be working for us with your config files and dependencies. We have created this sample repo https://github.com/wallabyjs/wallaby-3384, can you please clone, run npm i and run Wallaby to see if it work for you? The a.test.ts logs global crypto object that gets into globals from JSDOM (it is not node crypto), and replicache is built for browser, so it expects it.

If the sample repo works, please add the bits we're missing to reproduce the issue to the repo.

tslocke commented 2 months ago

With that repo I'm getting:

‍​[Info]​ Started Wallaby.js Core v1.0.1580
​​[Error] Failed to load configuration file: Automatic Vitest configuration error: Vitest dependency not found.​​
​​[Error] We've also tried to automatically configure Wallaby.js for other frameworks.​​
​​[Error] Automatic Jest configuration error: Module jest-cli is not found in '<rootDir>'.​​
​​[Error] Automatic node:test configuration error: Wallaby node:test integration requires Node.js 22.3.0 or higher. ​​
​​[Error] Please refer to our docs: https://wallabyjs.com/docs/config/overview.html ​​

Vitest is there in node_modules

I tried switching to the latest Node LTS (20.15.1) - same error

ArtemGovorov commented 2 months ago

With that repo I'm getting:

This is very strange, it is a very simple repo that works for us in the same environment.

Can you please double check that you have opened the repo's root in VS Code (and not a parent or some other folder)?

Screenshot 2024-07-17 at 7 54 54 PM

Also, have you used npm to install the dependencies?

tslocke commented 2 months ago

This is very strange

That's what I thought!

Yes it's definitely the right directory open

Also, have you used npm to install the dependencies?

Yes, 10.7.0

I edited package.json so that npm test runs vitest, and that works OK from the cli.

Maybe I need to force a full reinstall of wallaby?

ArtemGovorov commented 2 months ago

Very bizarre, it looks like wallaby is starting a wrong folder for some reason. Can you please try this:

console.log('cwd', process.cwd()); console.log('vitest', fs.existsSync(path.join(process.cwd(), 'node_modules/vitest')));


- run `Wallaby Select Configuration` command in the opened repo in VS Code and select `wallaby.mjs`,
- once Wallaby starts after it, open `Wallaby.js Console` output channel in VS Code and paste the output from there,
- also, after the start, please run `Wallaby Copy Diagnostics Report` in VS Code, and also paste the output.
tslocke commented 2 months ago

‍​[Info]​ Started Wallaby.js Core v1.0.1580 ​[Info]​ cwd /Users/tom/tmp/wallaby-3384 ​[Info]​ vitest true ​​[Error] Failed to load configuration file: Automatic Vitest configuration error: Vitest dependency not found.​​

{
  editorVersion: '1.89.1',
  pluginVersion: '1.0.379',
  editorType: 'VSCode',
  osVersion: 'darwin 23.5.0',
  nodeVersion: 'v20.15.1',
  coreVersion: '1.0.1580',
  checksum: 'MDY4NDhlNTcwYjk4YzYxNTVkNjYyYWI3M2Q2NTk4M2YsMTc0NTc5ODQwMDAwMCww',
  config: { tests: [], files: [] },
  packageJSON: {
    dependencies: {
      '@babel/standalone': '^7.24.5',
      '@codemirror/lang-css': '^6.2.1',
      '@codemirror/lang-javascript': '^6.2.1',
      '@codemirror/theme-one-dark': '^6.1.2',
      '@floating-ui/dom': '^1.2.6',
      '@mhsdesign/jit-browser-tailwindcss': '^0.4.0',
      '@sentry/browser': '^7',
      '@sentry/tracing': '^7',
      '@sentry/vite-plugin': '^2.16.0',
      '@solid-primitives/scheduled': '^1.4',
      '@solidjs/router': '^0.14',
      '@tanstack/solid-table': '^8.19',
      assert: '^2.1.0',
      axios: '^1.3.6',
      'babel-preset-solid': '^1.8',
      'base64-js': '^1.5.1',
      'browser-util-inspect': '^0.2.0',
      codemirror: '^6.0.1',
      'escape-html': '^1.0.3',
      'fast-array-diff': '^1.1.0',
      'fractional-indexing': '^3.2.0',
      fuzzy: '^0.1',
      'hotkeys-js': '^3.10.2',
      inflection: '^2.0.1',
      minisearch: '^6.0.1',
      mitt: '^3.0',
      nanoid: '^4.0.2',
      'next-tick': '^1.1',
      'prosemirror-commands': '^1.5',
      'prosemirror-dropcursor': '^1.8',
      'prosemirror-history': '^1.3',
      'prosemirror-inputrules': '^1.4',
      'prosemirror-keymap': '^1.2',
      'prosemirror-model': '^1.19',
      'prosemirror-state': '^1.4',
      'prosemirror-transform': '^1.8',
      'prosemirror-view': '^1.33',
      'pusher-js': '^8.0.2',
      ramda: '^0.29.0',
      replicache: '^12.2.1',
      'scroll-into-view-if-needed': '^3.0.10',
      snabbdom: '^3.6.2',
      'solid-boundaries': '^2.1.0',
      'solid-js': '^1.8',
      xregexp: '^5.1.1'
    },
    devDependencies: {
      '@babel/parser': '^7.24.5',
      '@babel/types': '^7.24.5',
      '@lezer/generator': '^1.5.1',
      '@solidjs/testing-library': '^0.8',
      '@tailwindcss/forms': '^0.5',
      '@tailwindcss/typography': '^0.5',
      '@types/babel__standalone': '^7.1.7',
      '@types/escape-html': '^1.0.2',
      '@types/inflection': '^1.13.0',
      '@types/json-pointer': '^1.0.31',
      '@types/next-tick': '^1.0.0',
      '@types/node': '^18.15.13',
      '@types/object-inspect': '^1.8.1',
      '@types/ramda': '^0.29.0',
      autoprefixer: '^10.4',
      'fake-indexeddb': '^6.0.0',
      jsdom: '^24.1.0',
      'json-beautify': '^1.1',
      'json-pointer': '^0.6.2',
      'object-inspect': '^1.12.3',
      'patch-package': '^8.0.0',
      postcss: '^8.4.14',
      'postcss-import': '^16.1.0',
      'postinstall-postinstall': '^2.1.0',
      'solid-devtools': '^0.30',
      'ts-unused-exports': '^9.0.4',
      typescript: '^5.4',
      vite: '^5.2',
      'vite-plugin-solid': '^2.10',
      'vite-tsconfig-paths': '^4.3',
      vitest: '^1.6'
    }
  },
  fs: { numberOfFiles: 0 },
  debug: [
    '2024-07-17T10:41:09.895Z project waiting for initial run signal\n',
    '2024-07-17T10:41:09.922Z model Initialization Completed: 519ms\n',
    '2024-07-17T10:41:09.943Z config Attempting automatic configuration for vitest\n',
    '2024-07-17T10:41:09.945Z vitest/config Error: Vitest dependency not found.\n' +
      '    at s.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:185:3465)\n' +
      '    at automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:13094)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12971)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12971)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12971)\n' +
      '    at async Config.load (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12911)\n' +
      '    at async Project.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:484:2644)\n',
    '2024-07-17T10:41:09.945Z config Finished attempting automatic configuration for vitest (2ms)\n',
    '2024-07-17T10:41:09.945Z config Attempting automatic configuration for angular\n',
    '2024-07-17T10:41:09.953Z angular/cli config Angular CLI not found.\n',
    '2024-07-17T10:41:09.954Z config Finished attempting automatic configuration for angular (9ms)\n',
    '2024-07-17T10:41:09.954Z config Attempting automatic configuration for jest\n',
    "2024-07-17T10:41:09.956Z jest/config Error: Module jest-cli is not found in '<homeDir>/tmp/wallaby-3384'.\n" +
      '    at Object.loadJest (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:497:1080)\n' +
      '    at i (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:184:24825)\n' +
      '    at s.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:184:28164)\n' +
      '    at automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:13094)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12971)\n' +
      '    at async Config.load (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12911)\n' +
      '    at async Project.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:484:2644)\n',
    '2024-07-17T10:41:09.956Z config Finished attempting automatic configuration for jest (2ms)\n',
    '2024-07-17T10:41:09.956Z config Attempting automatic configuration for node:test\n',
    '2024-07-17T10:41:09.957Z vitest/config Error: Wallaby node:test integration requires Node.js 22.3.0 or higher.\n' +
      '    at s.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:185:596)\n' +
      '    at automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:13094)\n' +
      '    at async Config.load (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:132:12911)\n' +
      '    at async Project.configure (<homeDir>/.cursor/extensions/wallabyjs.wallaby-vscode-1.0.379/wallabyf7c996/server.js:484:2644)\n',
    '2024-07-17T10:41:09.957Z config Finished attempting automatic configuration for node:test (1ms)\n',
    '2024-07-17T10:41:09.958Z project Failed to load configuration file: Automatic Vitest configuration error: Vitest dependency not found.\n' +
      '\n' +
      "We've also tried to automatically configure Wallaby.js for other frameworks.\n" +
      "Automatic Jest configuration error: Module jest-cli is not found in '<rootDir>'.\n" +
      'Automatic node:test configuration error: Wallaby node:test integration requires Node.js 22.3.0 or higher.\n'
  ]
}
tslocke commented 2 months ago

BTW I am using Cursor which is a fork of vs code. I tried your repo in plain VS Code and had the same problem. I'll run your diagnostics again in regular VS code...

...yep same results.

smcenlly commented 2 months ago

Can you please try creating a file in your project root:

wallaby-vitest-resolve.js

const Module = require('module');
const path = require('path');
const rootEntryModule = new Module('.', null);
rootEntryModule.filename = path.join(process.cwd(), 'root.js');
rootEntryModule.paths = Module._nodeModulePaths(process.cwd());

const modulePath = Module._resolveFilename('vitest/package.json', rootEntryModule, false);
console.log(modulePath);

and then run it from the command line and share the results.

Could you also check whether you have a .pnp.* file in any folders above your project folder? It's possible that this may cause an issue for you.

tslocke commented 2 months ago

Could you also check whether you have a .pnp.* file

Great catch : ) That fixed it. Sorry for the noise.