wallabyjs / public

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

Failed to initialize wallaby vitest. // Could not find vitest utils #3137

Closed tsteckenborn closed 1 year ago

tsteckenborn commented 1 year ago

Issue description or question

Trying to run Wallaby with Turborepo, TypeScript and Vitest with a Miniflare (Cloudflare Workers) environment. Unfortunately the Wallaby.js test output reports:

Failed to initialize wallaby vitest. 
Could not find vitest utils 
Error: Could not find vitest utils 

The issue could lie outside of Wallaby, though. npm run test with "test": "vitest run" yields expected tests running. npx vitest run yields in error Error: No test suite found in file ....

Wallaby diagnostics report

{
  editorVersion: '1.74.2',
  pluginVersion: '1.0.348',
  editorType: 'VSCode',
  osVersion: 'linux 5.15.49-linuxkit',
  nodeVersion: 'v18.12.1',
  coreVersion: '1.0.1363',
  checksum: 'ZDk5Nzk4ZjA1NWE2OTI2NjU1NTQ3YmViZGZjMGUyYjcsMTcwMDY5NzYwMDAwMCww',
  config: {
    diagnostics: {
      vitest: {
        file: {
          config: 'import { defineConfig } from "vitest/config";\n' +
            '\n' +
            'export default defineConfig({\n' +
            '\ttest: {\n' +
            '\t\tenvironment: "miniflare",\n' +
            '\t\t// Configuration is automatically loaded from `.env`, `package.json` and\n' +
            '\t\t// `wrangler.toml` files by default, but you can pass any additional Miniflare\n' +
            '\t\t// API options here:\n' +
            '\t\tenvironmentOptions: {\n' +
            '\t\t\tbindings: {},\n' +
            '\t\t\tkvNamespaces: [],\n' +
            '\t\t},\n' +
            '\t},\n' +
            '});\n'
        },
        config: {
          allowOnly: true,
          watch: true,
          globals: false,
          environment: 'miniflare',
          threads: true,
          clearMocks: false,
          restoreMocks: false,
          mockReset: false,
          include: [ '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}' ],
          exclude: [ '**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*' ],
          testTimeout: 5000,
          hookTimeout: 10000,
          teardownTimeout: 1000,
          isolate: true,
          watchExclude: [ '**/node_modules/**', '**/dist/**' ],
          forceRerunTriggers: [ '**/package.json/**', '**/{vitest,vite}.config.*/**' ],
          update: false,
          reporters: [ 'default' ],
          silent: false,
          ui: false,
          uiBase: '/__vitest__/',
          open: true,
          css: { include: [], modules: { classNameStrategy: 'stable' } },
          coverage: {
            provider: 'c8',
            enabled: false,
            clean: true,
            cleanOnRerun: false,
            reportsDirectory: './coverage',
            excludeNodeModules: true,
            exclude: [
              'coverage/**',
              'dist/**',
              'packages/*/test{,s}/**',
              '**/*.d.ts',
              'cypress/**',
              'test{,s}/**',
              'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
              '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
              '**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
              '**/__tests__/**',
              '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*',
              '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}'
            ],
            reporter: [ 'text', 'html', 'clover', 'json' ],
            allowExternal: false,
            extension: [
              '.js',  '.cjs',
              '.mjs', '.ts',
              '.mts', '.cts',
              '.tsx', '.jsx',
              '.vue', '.svelte'
            ]
          },
          fakeTimers: { loopLimit: 10000, shouldClearNativeTimers: true, toFake: [ 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate', 'Date' ] },
          maxConcurrency: 5,
          dangerouslyIgnoreUnhandledErrors: false,
          typecheck: {
            checker: 'tsc',
            include: [ '**/*.{test,spec}-d.{ts,js}' ],
            exclude: [ '**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*' ]
          },
          slowTestThreshold: 300,
          environmentOptions: { bindings: {}, kvNamespaces: [] },
          defines: {},
          root: '<rootDir>',
          mode: [],
          deps: { inline: [ {}, {}, {}, {}, {}, {}, '@nuxt/test-utils' ], registerNodeLoader: false },
          snapshotOptions: { snapshotFormat: {}, updateSnapshot: 'new' },
          setupFiles: [],
          cache: { dir: '<rootDir>/node_modules/.vitest' },
          sequence: { hooks: 'parallel' },
          package: {
            version: '0.26.2',
            urls: { hooks: 'file://<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/hooks.mjs' },
            paths: { root: '<rootDir>/node_modules/vitest', dist: '<rootDir>/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}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', 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}.config.*', ignore: true, trigger: true, load: true, file: true, test: 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}.config.*', ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', ignore: false, trigger: true, load: true, test: true, order: 2 }
    ],
    workers: { initial: 1, regular: 1, recycle: false },
    filesWithNoCoverageCalculated: [],
    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 },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: false,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: {
      type: 'node',
      params: { runner: '--experimental-loader=file://<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/hooks.mjs' },
      runner: '/usr/local/bin/node',
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: true,
    symlinkNodeModules: undefined,
    configCode: 'auto.detect#-2054068591'
  },
  packageJSON: {
    dependencies: { '@js-temporal/polyfill': '^0.4.3', '@zodios/core': '^10.7.1', '@cloudflare/itty-router-openapi': '^0.0.12', zod: '^3.20.2' },
    devDependencies: {
      '@cloudflare/workers-types': '^4.20221111.1',
      msw: '^0.49.2',
      typescript: '^4.9.4',
      vitest: '0.26.2',
      'vitest-environment-miniflare': '^2.11.0',
      '@vitest/coverage-c8': '^0.26.2',
      wrangler: '^2.6.2'
    }
  },
  fs: { numberOfFiles: 19 },
  debug: [
    '2022-12-30T14:07:53.879Z config Attempting automatic configuration for angular\n',
    '2022-12-30T14:07:53.881Z angular/cli config Angular CLI not found.\n',
    '2022-12-30T14:07:53.881Z config Finished attempting automatic configuration for angular (2ms)\n',
    '2022-12-30T14:07:53.881Z config Attempting automatic configuration for jest\n',
    "2022-12-30T14:07:53.882Z jest/config Error: Module jest-cli is not found in '<rootDir>'.\n" +
      '    at Object.<anonymous> (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:25202)\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:8268)\n' +
      '    at Object.next (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:7563)\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:7472\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at s (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:7266)\n' +
      '    at Object.loadJest (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:31:22800)\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:22845\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:27578)\n' +
      '    at Object.next (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26873)\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26782\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at s (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26576)\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:22533)\n' +
      '    at Object.<anonymous> (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26253)\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:27578)\n' +
      '    at Object.next (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26873)\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26782\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at s (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26576)\n' +
      '    at Object.n [as configure] (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:19:26134)\n' +
      '    at Config.<anonymous> (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:15:20840)\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:15:12061)\n' +
      '    at Object.next (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:15:11356)\n' +
      '    at o (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/server.js:15:11105)\n',
    '2022-12-30T14:07:53.882Z config Finished attempting automatic configuration for jest (1ms)\n',
    '2022-12-30T14:07:53.882Z config Attempting automatic configuration for vitest\n',
    '2022-12-30T14:07:53.884Z vitest/config Detected Vitest (0.26.2).\n',
    '2022-12-30T14:07:54.234Z config Finished attempting automatic configuration for vitest (352ms)\n',
    '2022-12-30T14:07:54.235Z project Wallaby Node version: v18.12.1\n',
    '2022-12-30T14:07:54.235Z project Wallaby config: <rootDir>/auto.detect\n',
    '2022-12-30T14:07:54.243Z fs File system starting\n',
    '2022-12-30T14:07:54.269Z fs File system scan completed\n',
    '2022-12-30T14:07:54.273Z project File cache: <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/projects/017d627069bb5606\n',
    '2022-12-30T14:07:54.308Z uiService Listening port 51235\n',
    '2022-12-30T14:07:54.314Z workers Parallelism for initial run: 1, for regular run: 1\n',
    '2022-12-30T14:07:54.315Z workers Starting run worker instance #0\n',
    '2022-12-30T14:07:54.315Z workers Web server is listening at 33737\n',
    '2022-12-30T14:07:54.319Z project Stopping process pool\n',
    '2022-12-30T14:07:54.319Z project File cache is up-to-date, starting full test run\n',
    '2022-12-30T14:07:54.320Z project Test run started; run priority: 3\n',
    '2022-12-30T14:07:54.320Z project Running all tests\n',
    '2022-12-30T14:07:54.321Z workers Starting test run, priority: 3\n',
    '2022-12-30T14:07:54.322Z nodeRunner Starting sandbox [worker #0, session #t2y6q]\n',
    '2022-12-30T14:07:54.322Z nodeRunner Preparing sandbox [worker #0, session #t2y6q]\n',
    '2022-12-30T14:07:54.435Z workers Started run worker instance (delayed) #0\n',
    '2022-12-30T14:07:54.435Z nodeRunner Prepared sandbox [worker #0, session #t2y6q]\n',
    '2022-12-30T14:07:54.435Z workers [worker #0, session #t2y6q] Running tests in sandbox\n',
    '2022-12-30T14:07:54.448Z workers Sandbox (active) [t2y6q] error: Failed to initialize wallaby vitest.\n' +
      'Could not find vitest utils\n' +
      'Error: Could not find vitest utils\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at WebSocket.emit (node:events:513:28)\n' +
      '    at afterWrite (node:internal/streams/writable:500:5)\n' +
      '    at onwrite (node:internal/streams/writable:480:7)\n' +
      '    at Zlib.cb (node:internal/streams/transform:190:7)\n' +
      '    at Zlib.processCallback (node:zlib:613:8)\n',
    '2022-12-30T14:07:54.550Z workers [t2y6q] Run 0 test(s), skipped 0 test(s)\n',
    '2022-12-30T14:07:54.552Z workers [t2y6q] Sandbox is responsive, closing it\n',
    '2022-12-30T14:07:54.553Z workers Failed to map the stack to user code, entry message: Failed to initialize wallaby vitest.\n' +
      'Could not find vitest utils\n' +
      'Error: Could not find vitest utils, stack: Failed to initialize wallaby vitest.\n' +
      'Could not find vitest utils\n' +
      'Error: Could not find vitest utils\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:4158\n' +
      '    at r (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:9779)\n' +
      '    at Object.next (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:9074)\n' +
      '    at <homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:8973\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at __awaiter (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:8767)\n' +
      '    at initializeVitest (<homeDir>/.vscode-server/extensions/wallabyjs.wallaby-vscode-1.0.348/wallaby3bcdb4/runners/node/vitest@0.14.0/initializer.js:14:19\n',
    '2022-12-30T14:07:54.554Z project Test run finished\n',
    '2022-12-30T14:07:54.554Z project Processed console.log entries\n',
    '2022-12-30T14:07:54.554Z project Processed loading sequences\n',
    '2022-12-30T14:07:54.554Z project Processed executed tests\n',
    '2022-12-30T14:07:54.554Z project Processed code coverage\n',
    '2022-12-30T14:07:54.557Z project Test run result processed and sent to IDE\n'
  ]
}
smcenlly commented 1 year ago

The Wallaby error that you are getting indicates that Wallaby couldn't find and patch the necessary vitest files for some reason. We set up a new sample project with your dependencies and configuration and were unable to reproduce your problem.

Could you please try:

  1. Deleting your node_modules folder for your project root
  2. Deleting package-lock.json or yarn.lock file(s) in your project root
  3. Reinstalling your packages (i.e. using your package manager, npm or yarn)
  4. Then restart Wallaby (to see if that fixes your problem)

If you're still having problems, could you please try creating a sample repo that has the same problem and ensure that you can clone and reproduce the error in a new folder? If so, please provide us with the same repo and we should be able to determine why it's not working for you.

smcenlly commented 1 year ago

Closing this issue as we haven't heard back. If you're still having the problem, please let us know and we'll re-open the issue.