wallabyjs / public

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

Runtime error: ReferenceError: url is not defined #3254

Closed TeaBough closed 1 year ago

TeaBough commented 1 year ago

I'm getting this error :

image

I really don't know how I can fix that, the test is working fine when running with vite cli...

{
  editorVersion: 'IntelliJ IDEA 2023.2',
  pluginVersion: '1.0.270',
  editorType: 'IntelliJ',
  osVersion: 'linux 6.2.6-76060206-generic',
  nodeVersion: 'v16.14.0',
  coreVersion: '1.0.1454',
  checksum: 'NjFjNGQ4NGNlZWE4Y2RlZmI0MWQwMWVhODdmMjcyNTUsMTcwMjA4MDAwMDAwMCww',
  config: {
    localProjectDir: '<homeDir>/src/projet/app/',
    projectCacheDir: '<homeDir>/.cache/JetBrains/IntelliJIdea2023.2/wallaby/projects/5ace56e8f3a13773/instrumented',
    compilers: { coffeeScript: [Function (anonymous)], babel: [Function (anonymous)], typeScript: [Function: typeScript] },
    postprocessors: { typeScript: [Function (anonymous)], webpack: [Function (anonymous)] },
    override: [Function: override],
    defaults: { files: { ignore: false, trigger: true, load: true, instrument: true }, tests: { ignore: false, trigger: true, load: true } },
    files: [
      { pattern: 'src/**/*.js', ignore: false, trigger: true, load: true, instrument: true, order: 1 },
      { pattern: 'src/**/*.tsx', ignore: false, trigger: true, load: true, instrument: true, order: 2 },
      { pattern: 'src/**/*.ts', ignore: false, trigger: true, load: true, instrument: true, order: 3 },
      { pattern: 'src/**/*.test.ts', ignore: true, trigger: true, load: true, instrument: true, file: true },
      { pattern: 'src/**/*.test.tsx', ignore: true, trigger: true, load: true, instrument: true, file: true }
    ],
    tests: [
      { pattern: 'src/**/*.test.ts', ignore: false, trigger: true, load: true, test: true, order: 4 },
      { pattern: 'src/**/*.test.tsx', ignore: false, trigger: true, load: true, test: true, order: 5 }
    ],
    diagnostics: {
      vitest: {
        file: {
          config: '/// <reference types="vitest" />\n' +
            "import { defineConfig } from 'vite';\n" +
            "import tsconfigPaths from 'vite-tsconfig-paths';\n" +
            '// @ts-ignore\n' +
            "import svgrPlugin from 'vite-plugin-svgr';\n" +
            "import react from '@vitejs/plugin-react';\n" +
            '\n' +
            "const path = require('path');\n" +
            '\n' +
            '// https://vitejs.dev/config/\n' +
            'export default defineConfig({\n' +
            '  resolve: {\n' +
            '    alias: {\n' +
            "      '@tailwindConfig': path.resolve(__dirname, 'tailwind.config.cjs'),\n" +
            '    },\n' +
            '  },\n' +
            '  optimizeDeps: {\n' +
            "    include: ['@tailwindConfig'],\n" +
            '  },\n' +
            '  plugins: [\n' +
            '    react({\n' +
            '      babel: {\n' +
            '        presets: [\n' +
            '          [\n' +
            "            '@babel/preset-react',\n" +
            "            { runtime: 'automatic', importSource: '@emotion/react' },\n" +
            '          ],\n' +
            '        ],\n' +
            '\n' +
            '        plugins: [\n' +
            "          '@emotion/babel-plugin',\n" +
            '          [\n' +
            "            'babel-plugin-twin',\n" +
            '            {\n' +
            '              // cf https://github.com/ben-rogerson/babel-plugin-twin/issues/9\n' +
            '              exclude: [\n' +
            "                '\\x00commonjsHelpers.js', // Avoid build error\n" +
            '              ],\n' +
            '            },\n' +
            '          ],\n' +
            "          'babel-plugin-macros',\n" +
            '        ],\n' +
            '      },\n' +
            '    }),\n' +
            '    tsconfigPaths(),\n' +
            '    svgrPlugin(),\n' +
            '  ],\n' +
            '  server: {\n' +
            '    port: 9003,\n' +
            '  },\n' +
            '  test: {\n' +
            '    globals: true,\n' +
            '    testTimeout: 120000,\n' +
            '    // maxThreads: 1,\n' +
            '    // minThreads: 1,\n' +
            "    environment: 'jsdom',\n" +
            "    setupFiles: ['./src/testing/setupTests.ts'],\n" +
            '    exclude: [\n' +
            "      './e2e',\n" +
            "      '**/node_modules/**',\n" +
            "      '**/dist/**',\n" +
            "      '**/.{idea,git,cache,output,temp}/**',\n" +
            "      '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,tsup,build}.config.*',\n" +
            '    ],\n' +
            '  },\n' +
            '});\n'
        },
        config: {
          allowOnly: true,
          watch: true,
          globals: true,
          environment: 'jsdom',
          threads: true,
          clearMocks: false,
          restoreMocks: false,
          mockReset: false,
          include: [ '**/*.{test,spec}.?(c|m)[jt]s?(x)' ],
          exclude: [ './e2e', '**/node_modules/**', '**/dist/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,tsup,build}.config.*' ],
          testTimeout: 120000,
          hookTimeout: 10000,
          teardownTimeout: 10000,
          isolate: true,
          watchExclude: [ '**/node_modules/**', '**/dist/**' ],
          forceRerunTriggers: [ '**/package.json/**', '**/{vitest,vite}.config.*/**', '<homeDir>/src/projet/app/src/testing/setupTests.ts' ],
          update: false,
          reporters: [ 'default' ],
          silent: false,
          hideSkippedTests: false,
          ui: false,
          uiBase: '/__vitest__/',
          open: true,
          css: { include: [], modules: { classNameStrategy: 'stable' } },
          coverage: {
            provider: 'v8',
            enabled: false,
            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}.?(c|m)[jt]s?(x)',
              '**/__tests__/**',
              '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
              '**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}',
              'src/testing/setupTests.ts',
              'src/testing/setupTests.ts'
            ],
            reportOnFailure: false,
            reporter: [ [ 'text', {} ], [ 'html', {} ], [ 'clover', {} ], [ 'json', {} ] ],
            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.?(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}.config.*'
            ]
          },
          slowTestThreshold: 300,
          setupFiles: [ '<homeDir>/src/projet/app/src/testing/setupTests.ts' ],
          defines: {},
          root: '<homeDir>/src/projet/app',
          mode: [],
          inspect: false,
          inspectBrk: false,
          singleThread: false,
          deps: { moduleDirectories: [ '/node_modules/' ] },
          server: { deps: { inline: [ {}, {}, {}, '@nuxt/test-utils' ], moduleDirectories: [ '/node_modules/' ], cacheDir: 'node_modules/.vitest' } },
          snapshotOptions: { snapshotFormat: {}, updateSnapshot: 'new', snapshotEnvironment: null },
          experimentalVmWorkerMemoryLimit: 8410462208,
          cache: { dir: '<homeDir>/src/projet/app/node_modules/.vitest' },
          sequence: { hooks: 'parallel' },
          environmentMatchGlobs: [],
          browser: { enabled: false, headless: false, slowHijackESM: true, api: { port: 63315 } },
          testTransformMode: {},
          package: {
            version: '0.34.1',
            urls: { hooks: 'file://<homeDir>/.cache/JetBrains/IntelliJIdea2023.2/wallaby/wallaby/runners/node/hooks.mjs' },
            paths: {
              root: '<homeDir>/src/projet/node_modules/.pnpm/vitest@0.34.1_@vitest+ui@0.34.1_jsdom@22.0.0_terser@5.17.3/node_modules/vitest',
              dist: '<homeDir>/src/projet/node_modules/.pnpm/vitest@0.34.1_@vitest+ui@0.34.1_jsdom@22.0.0_terser@5.17.3/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,
    workers: { initial: 1, regular: 1, recycle: false },
    captureConsoleLog: true,
    filesWithNoCoverageCalculated: [],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    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|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>/.cache/JetBrains/IntelliJIdea2023.2/wallaby/wallaby/runners/node/hooks.mjs' },
      runner: '<homeDir>/.nvm/versions/node/v16.14.0/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: 'module.exports = wallaby => ({\n' +
      '  ...wallaby,\n' +
      '  autoDetect: true,\n' +
      '  files: [\n' +
      "    './src/**/*.js',\n" +
      "    './src/**/*.tsx',\n" +
      "    './src/**/*.ts',\n" +
      "    { pattern: 'src/**/*.test.ts', ignore: true },\n" +
      "    { pattern: 'src/**/*.test.tsx', ignore: true },\n" +
      '  ],\n' +
      "  tests: ['src/**/*.test.ts', 'src/**/*.test.tsx'],\n" +
      '});\n'
  },
  packageJSON: {
    dependencies: {
      '@floating-ui/react-dom': '^2.0.1',
      '@headlessui/react': '^1.7.15',
      '@react-oauth/google': '^0.11.0',
      axios: '^1.4.0',
      clsx: '^1.2.1',
      'date-arithmetic': '^4.1.0',
      'date-fns': '^2.30.0',
      'file-saver': '^2.0.5',
      filesize: '^10.0.7',
      fontfaceobserver: '2.3.0',
      'hoist-non-react-statics': '3.3.2',
      'js-cookie': '^3.0.5',
      lodash: '^4.17.21',
      'lodash-es': '4.17.21',
      'match-sorter': '^6.3.1',
      nanoid: '^4.0.2',
      polished: '^4.1.2',
      'posthog-js': '^1.75.3',
      qs: '^6.11.0',
      react: '^18.2.0',
      'replace-in-file': '^6.3.5',
      'sanitize.css': '13.0.0',
      'shallow-equal': '^3.1.0',
      'twin.macro': '^3.1.0',
      'typeface-inter': '^3.18.1',
      'use-debounce': '^9.0.4',
      'use-fit-text': '^2.4.0',
      uuid: '^9.0.0',
      validator: '^13.9.0',
      'workbox-window': '^6.5.4'
    },
    devDependencies: {
      '@babel/core': '^7.21.8',
      '@babel/preset-env': '^7.21.5',
      '@babel/preset-react': '7.18.6',
      '@emotion/babel-plugin': '^11.11.0',
      '@emotion/babel-plugin-jsx-pragmatic': '^0.2.1',
      '@playwright/test': '^1.33.0',
      '@popperjs/core': '^2.11.7',
      '@remix-run/web-fetch': '^4.3.4',
      '@tailwindcss/forms': '^0.5.3',
      '@tailwindcss/typography': '^0.5.9',
      '@testing-library/dom': '9.3.0',
      '@testing-library/jest-dom': '5.16.5',
      '@testing-library/react': '14.0.0',
      '@testing-library/user-event': '^14.4.3',
      '@types/hoist-non-react-statics': '3.3.1',
      '@types/lodash': '4.14.194',
      '@types/lodash-es': '4.17.7',
      '@types/node': '16.18.12',
      '@types/react': '18.2.6',
      '@types/react-beautiful-dnd': '13.1.4',
      '@types/react-dom': '18.2.4',
      '@types/testing-library__jest-dom': '^5.14.5',
      '@typescript-eslint/eslint-plugin': '5.59.5',
      '@typescript-eslint/parser': '5.59.5',
      '@vitejs/plugin-legacy': '^4.1.1',
      '@vitejs/plugin-react': '^4.0.4',
      '@vitest/runner': '^0.34.1',
      '@vitest/ui': '^0.34.1',
      'babel-plugin-macros': '^3.1.0',
      'babel-plugin-preval': '^5.1.0',
      'babel-plugin-twin': '^1.1.0',
      'cross-env': '^7.0.3',
      dns: '^0.2.2',
      dotenv: '^16.0.3',
      eslint: '8.40.0',
      esm: '3.2.25',
      'froala-editor': '4.0.18',
      'intersection-observer': '^0.12.2',
      'jotai-devtools': '^0.5.3',
      jsdom: '^22.0.0',
      'lint-staged': '13.2.2',
      msw: '1.2.1',
      prettier: '^2.8.8',
      'prop-types': '^15.8.1',
      'react-fast-compare': '^3.2.1',
      'react-froala-wysiwyg': '4.0.18',
      'react-grid-layout': '1.3.4',
      'react-input-autosize': '^3.0.0',
      'react-select-event': '^5.5.1',
      'react-sizeme': '^3.0.1',
      rimraf: '^5.0.0',
      tailwindcss: '^3.2.7',
      typescript: '^5.0.4',
      'utility-types': '^3.10.0',
      vite: '^4.4.9',
      'vite-node': '^0.34.1',
      'vite-plugin-pwa': '^0.16.4',
      'vite-plugin-svgr': '^3.2.0',
      'vite-tsconfig-paths': '^4.2.0',
      vitest: '^0.34.1'
    }
  },
  fs: { numberOfFiles: 2101 },
  debug: []
}
smcenlly commented 1 year ago

I've removed node_modules and reupdated everything (vitest, intellij, wallaby).

Did you also delete pnpm-lock.yaml before reinstalling the modules? This is where we think you may have a problem.

We took your exact dependencies from your diagnostics report and it works for us, but we did receive a number of warnings after installing dependencies:

WARN Issues with peer dependencies found
.
├─┬ @testing-library/react 14.0.0
│ └── ✕ missing peer react-dom@^18.0.0
├─┬ jotai-devtools 0.5.3
│ ├─┬ @mantine/core 6.0.18
│ │ ├── ✕ missing peer react-dom@>=16.8.0
│ │ ├─┬ @mantine/styles 6.0.18
│ │ │ └── ✕ missing peer react-dom@>=16.8.0
│ │ ├─┬ @radix-ui/react-scroll-area 1.0.2
│ │ │ ├── ✕ missing peer react-dom@"^16.8 || ^17.0 || ^18.0"
│ │ │ ├─┬ @radix-ui/react-presence 1.0.0
│ │ │ │ └── ✕ missing peer react-dom@"^16.8 || ^17.0 || ^18.0"
│ │ │ └─┬ @radix-ui/react-primitive 1.0.1
│ │ │   └── ✕ missing peer react-dom@"^16.8 || ^17.0 || ^18.0"
│ │ └─┬ @floating-ui/react 0.19.2
│ │   ├── ✕ missing peer react-dom@>=16.8.0
│ │   └─┬ @floating-ui/react-dom 1.3.0
│ │     └── ✕ missing peer react-dom@>=16.8.0
│ ├─┬ @mantine/prism 6.0.18
│ │ └── ✕ missing peer react-dom@>=16.8.0
│ └─┬ react-resizable-panels 0.0.42
│   └── ✕ missing peer react-dom@"^16.14.0 || ^17.0.0 || ^18.0.0"
├─┬ react-froala-wysiwyg 4.0.18
│ └── ✕ missing peer react-dom@"~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
├─┬ react-grid-layout 1.3.4
│ ├── ✕ missing peer react-dom@">= 16.3.0"
│ └─┬ react-draggable 4.4.5
│   └── ✕ missing peer react-dom@">= 16.3.0"
├─┬ react-sizeme 3.0.1
│ ├── ✕ missing peer react-dom@"^0.14.0 || ^15.0.0-0 || ^16.0.0 || ^17.0.0"
│ └── ✕ unmet peer react@"^0.14.0 || ^15.0.0-0 || ^16.0.0 || ^17.0.0": found 18.2.0
├─┬ @floating-ui/react-dom 2.0.1
│ └── ✕ missing peer react-dom@>=16.8.0
├─┬ @headlessui/react 1.7.15
│ └── ✕ missing peer react-dom@"^16 || ^17 || ^18"
├─┬ @react-oauth/google 0.11.0
│ └── ✕ missing peer react-dom@>=16.8.0
├─┬ react-input-autosize 3.0.0
│ └── ✕ unmet peer react@"^16.3.0 || ^17.0.0": found 18.2.0
└─┬ vite-plugin-pwa 0.16.4
  └── ✕ unmet peer workbox-window@^7.0.0: found 6.5.4
✕ Conflicting peer dependencies:
  react-dom

I don't have the same error now... I'm getting Runtime error: ReferenceError: url is not defined

Unfortunately we introduced a bug recently when added support for the latest version of vitest where we are not correctly reporting incompatible vitest versions anymore. There's an incompatible version warning that is not being reported correctly. Please update to Wallaby core v1.0.1455 and you will get the correct error message.

Having said that, I suspect fixing the dependencies issues will fix your problem.


If you're still having problems, please provide us with your latest pnpm-lock.yaml file. I think it will allow us to reproduce your exact dependency structure and provide more specific advice on how to fix the problem.

TeaBough commented 1 year ago

Thanks ! ... removing pnpm-lock.yaml did not make it work but sadly, turning off and on my machine did 😢 Anyway, it seems to work now... thanks for the help ! 🙏