wallabyjs / public

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

Runtime error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package #3026

Closed keinsell closed 2 years ago

keinsell commented 2 years ago

Issue description or question

Wallaby doesn't really work in my monorepo. It found files but somehow it doesn't see like node_modules directory which causes errors.

Wallaby diagnostics report

{
  editorVersion: '1.68.1',
  pluginVersion: '1.0.344',
  editorType: 'VSCode',
  osVersion: 'linux 5.4.0-1074-azure',
  nodeVersion: 'v18.3.0',
  coreVersion: '1.0.1296',
  config: {
    testFramework: { version: 'ava@1.0.0', configurator: 'ava@1.0.0', reporter: 'ava@1.0.0', starter: 'ava@1.0.0' },
    files: [
      { pattern: 'services/**/package.json', load: true, ignore: false, trigger: true, instrument: true, order: 1 },
      { pattern: 'services/**/src/**/*', load: true, ignore: false, trigger: true, instrument: true, order: 2 },
      { pattern: 'services/**/src/**/*.spec.ts', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: 'services/**/test/**/*.spec.ts', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: 'services/*/node_modules/**', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: 'node_modules/**', ignore: true, trigger: true, load: true, instrument: true }
    ],
    tests: [
      { pattern: 'services/**/src/**/*.spec.ts', load: true, ignore: false, trigger: true, test: true, order: 3 },
      { pattern: 'services/**/test/**/*.spec.ts', load: true, ignore: false, trigger: true, test: true, order: 4 }
    ],
    env: {
      type: 'node',
      runner: 'node',
      params: {
        runner: '--loader=tsx --experimental-vm-modules --es-module-specifier-resolution=node --experimental-loader "file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs"',
        env: 'DATABASE_URL=postgresql://root@localhost:26257/defaultdb?sslmode=disable'
      },
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    symlinkNodeModules: false,
    workers: { restart: true, initial: 0, regular: 0, recycle: true },
    debug: true,
    compilers: { '**/*.?(lit)coffee?(.md)': [Function (anonymous)] },
    diagnostics: {},
    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/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: false,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    loose: undefined,
    configCode: 'module.exports = function (w) {\n' +
      '  return {\n' +
      "    /** It's not available for stack used in project, should be `false` */\n" +
      '    autoDetect: false,\n' +
      '    /** Framework used for tests, in our case `ava` */\n' +
      '    testFramework: "ava",\n' +
      '\n' +
      '    /** SmartStart defines points when and where wallby should start tests. */\n' +
      '    smartStart: [\n' +
      '      {\n' +
      '        startMode: "always",\n' +
      '        pattern: "services/**/src/**/*.spec.ts",\n' +
      '      },\n' +
      '      {\n' +
      '        startMode: "always",\n' +
      '        pattern: "services/**/test/**/*.ts",\n' +
      '      },\n' +
      '    ],\n' +
      '\n' +
      '    /** Regex for finding source of our application */\n' +
      '    files: [\n' +
      '      // { pattern: "package.json", load: true },\n' +
      '      { pattern: "services/**/package.json", load: true },\n' +
      '      { pattern: "services/**/src/**/*", load: true },\n' +
      '      { pattern: "services/**/src/**/*.spec.ts", ignore: true },\n' +
      '      { pattern: "services/**/test/**/*.spec.ts", ignore: true },\n' +
      '      {\n' +
      '        pattern: "services/*/node_modules/**",\n' +
      '        ignore: true,\n' +
      '        trigger: true,\n' +
      '        load: true,\n' +
      '        instrument: true,\n' +
      '      },\n' +
      '      {\n' +
      '        pattern: "node_modules/**",\n' +
      '        ignore: true,\n' +
      '        trigger: true,\n' +
      '        load: true,\n' +
      '        instrument: true,\n' +
      '      },\n' +
      '      // { pattern: "services/**/node_modules/**", ignore: true },\n' +
      '    ],\n' +
      '\n' +
      '    /** Regex for finding tests of our application */\n' +
      '    tests: [\n' +
      '      { pattern: "services/**/src/**/*.spec.ts", load: true },\n' +
      '      { pattern: "services/**/test/**/*.spec.ts", load: true },\n' +
      '      // { pattern: "services/**/node_modules/**", ignore: true },\n' +
      '    ],\n' +
      '\n' +
      '    env: {\n' +
      '      type: "node",\n' +
      '      runner: "node",\n' +
      '      params: {\n' +
      '        runner: `--loader=tsx --experimental-vm-modules --es-module-specifier-resolution=node`,\n' +
      '        env: "DATABASE_URL=postgresql://root@localhost:26257/defaultdb?sslmode=disable",\n' +
      '      },\n' +
      '    },\n' +
      '\n' +
      '    symlinkNodeModules: false,\n' +
      '    workers: { restart: true },\n' +
      '\n' +
      '    /** Wallaby is fucking broken... */\n' +
      '    debug: true,\n' +
      '\n' +
      '    /**\n' +
      '     * If your project root has a tsconfig.json file, wallaby.js will automatically use TypeScript compiler options configured in that file. Wallaby does not read nested tsconfig.json files that may exist in sub-directories. Please note that to perform TypeScript compilation faster, wallaby.js changes some TypeScript compiler options (see the details below).\n' +
      '     */\n' +
      '    compilers: {\n' +
      '      // "services/server/**/*.ts": w.compilers.typeScript({ module: "esnext" }),\n' +
      '      "**/*.ts": w.compilers.typeScript({\n' +
      '        module: "esnext",\n' +
      '        moduleResolution: "node",\n' +
      '        esModuleInterop: true,\n' +
      '      }),\n' +
      '    },\n' +
      '  };\n' +
      '};\n'
  },
  packageJSON: {
    dependencies: undefined,
    devDependencies: {
      '@changesets/changelog-git': '0.1.11',
      '@changesets/changelog-github': '0.4.5',
      '@changesets/cli': '2.23.0',
      '@commitlint/cli': '17.0.3',
      '@commitlint/config-conventional': '17.0.3',
      '@typescript-eslint/eslint-plugin': '^5.30.3',
      '@typescript-eslint/parser': '^5.27.1',
      ava: '4.3.0',
      eslint: '^8.18.0',
      esm: '^3.2.25',
      husky: '8.0.1',
      'is-ci': '3.0.1',
      jshint: '2.13.4',
      'lint-staged': '13.0.3',
      'prettier-config': 'workspace:*',
      rome: 'next',
      tsx: '^3.6.0',
      turbo: 'latest',
      typescript: '4.8.0-dev.20220701'
    }
  },
  fs: { numberOfFiles: 28 },
  debug: [
    '2022-07-03T14:01:57.042Z project Wallaby Node version: v18.3.0\n',
    '2022-07-03T14:01:57.043Z project Wallaby config: <rootDir>/wallaby.js\n',
    '2022-07-03T14:01:59.777Z project File cache: <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2\n',
    '2022-07-03T14:01:59.837Z uiService Listening port 51235\n',
    '2022-07-03T14:01:59.848Z project Config file change detected, invalidating local cache\n',
    '2022-07-03T14:01:59.857Z workers Parallelism for initial run: 2, for regular run: 2\n',
    '2022-07-03T14:01:59.857Z workers Starting run worker instance #0\n',
    '2022-07-03T14:01:59.858Z workers Starting run worker instance #1\n',
    '2022-07-03T14:01:59.858Z workers Web server is listening at 34661\n',
    '2022-07-03T14:01:59.858Z project File cache requires some updates, waiting required files from IDE\n',
    '2022-07-03T14:02:00.283Z workers Started run worker instance (delayed) #1\n',
    '2022-07-03T14:02:00.349Z workers Started run worker instance (delayed) #0\n',
    '2022-07-03T14:02:00.695Z project Stopping process pool\n',
    '2022-07-03T14:02:00.706Z project Running postprocessor\n',
    '2022-07-03T14:02:00.709Z postprocessor New TypeScript language service is required\n',
    "2022-07-03T14:02:00.709Z postprocessor Error parsing tsconfig file <rootDir>/tsconfig.json\n(ENOENT: no such file or directory, open '<rootDir>/tsconfig.json')\n",
    '2022-07-03T14:02:00.709Z postprocessor Error reading tsconfig file from <rootDir>/tsconfig.json\n' +
      "(Cannot find module '<rootDir>/tsconfig.json'\n" +
      'Require stack:\n' +
      '- <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/server.js)\n',
    '2022-07-03T14:02:01.451Z project Postprocessor execution finished\n',
    '2022-07-03T14:02:01.451Z project Test run started; run priority: 3\n',
    '2022-07-03T14:02:01.452Z project Running all tests\n',
    '2022-07-03T14:02:01.453Z workers Starting test run, priority: 3\n',
    '2022-07-03T14:02:01.454Z workers Distributing tests between 2 workers\n',
    '2022-07-03T14:02:01.454Z workers Running tests in parallel\n',
    '2022-07-03T14:02:01.454Z nodeRunner Starting sandbox [worker #0, session #teabr]\n',
    '2022-07-03T14:02:01.454Z nodeRunner Starting sandbox [worker #1, session #6cv6n]\n',
    '2022-07-03T14:02:01.454Z nodeRunner Preparing sandbox [worker #0, session #teabr]\n',
    '2022-07-03T14:02:01.455Z nodeRunner Preparing sandbox [worker #1, session #6cv6n]\n',
    '2022-07-03T14:02:01.455Z nodeRunner Prepared sandbox [worker #0, session #teabr]\n',
    '2022-07-03T14:02:01.455Z nodeRunner Prepared sandbox [worker #1, session #6cv6n]\n',
    '2022-07-03T14:02:01.455Z workers [worker #0, session #teabr] Running tests in sandbox\n',
    '2022-07-03T14:02:01.456Z workers [worker #1, session #6cv6n] Running tests in sandbox\n',
    '2022-07-03T14:02:01.755Z workers [6cv6n] Loaded unknown number of test(s)\n',
    "2022-07-03T14:02:01.758Z workers Sandbox (active) [teabr] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from ./services/server/src/domain/metric/metric.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.762Z workers Failed to map the stack to user code, entry message: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/metric/metric.spec.js\n" +
      "Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/metric/metric.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:3:21)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.764Z workers Sandbox (active) [6cv6n] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from ./services/server/src/domain/user/user.integration.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.764Z workers Failed to map the stack to user code, entry message: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/user/user.integration.spec.js\n" +
      "Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/user/user.integration.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:3:21)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    '2022-07-03T14:02:01.765Z workers [teabr] Loaded unknown number of test(s)\n',
    "2022-07-03T14:02:01.768Z workers Sandbox (active) [6cv6n] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from ./services/server/src/domain/user/user.integration.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.774Z workers Failed to map the stack to user code, entry message: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/user/user.integration.spec.js\n" +
      "Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/user/user.integration.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:8:10)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.774Z workers Sandbox (active) [teabr] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from ./services/server/src/domain/metric/metric.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.775Z workers Failed to map the stack to user code, entry message: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/metric/metric.spec.js\n" +
      "Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/domain/metric/metric.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:8:10)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.777Z workers Sandbox (active) [teabr] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from ./services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.777Z workers Failed to map the stack to user code, entry message: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      "Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ava' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      'Did you mean to import ava@4.3.0_@ava+typescript@3.0.1/node_modules/ava/entrypoints/main.cjs?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:3:21)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.781Z workers Sandbox (active) [teabr] error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@faker-js/faker' imported from ./services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      'Did you mean to import @faker-js+faker@7.3.0/node_modules/@faker-js/faker/dist/cjs/index.js?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    "2022-07-03T14:02:01.782Z workers Failed to map the stack to user code, entry message: Cannot find package '@faker-js/faker' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      "Did you mean to import @faker-js+faker@7.3.0/node_modules/@faker-js/faker/dist/cjs/index.js?, stack: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@faker-js/faker' imported from <homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/projects/9437d449f6025a2f_2/instrumented/services/server/src/infrastructure/encryption/encryption.spec.js\n" +
      'Did you mean to import @faker-js+faker@7.3.0/node_modules/@faker-js/faker/dist/cjs/index.js?\n' +
      '    at new NodeError (node:internal/errors:377:5)\n' +
      '    at packageResolve (node:internal/modules/esm/resolve:910:9)\n' +
      '    at moduleResolve (node:internal/modules/esm/resolve:959:20)\n' +
      '    at defaultResolve (node:internal/modules/esm/resolve:1174:11)\n' +
      '    at resolve (file://<homeDir>/.vscode-remote/extensions/wallabyjs.wallaby-vscode-1.0.344/wallabyc3cc8f/runners/node/ava@1.0.0/hooks-v2.mjs:8:10)\n' +
      '    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)\n' +
      '    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)\n' +
      '    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)\n' +
      '    at link (node:internal/modules/esm/module_job:78:36)\n',
    '2022-07-03T14:02:01.790Z workers [6cv6n] Run 0 test(s), skipped 0 test(s)\n',
    '2022-07-03T14:02:01.791Z workers [teabr] Run 0 test(s), skipped 0 test(s)\n',
    '2022-07-03T14:02:01.792Z workers [teabr] Sandbox is responsive, closing it\n',
    '2022-07-03T14:02:01.793Z workers Recyling run worker instance #0\n',
    '2022-07-03T14:02:01.793Z workers Starting run worker instance #0\n',
    '2022-07-03T14:02:01.806Z workers [6cv6n] Sandbox is responsive, closing it\n',
    '2022-07-03T14:02:01.806Z workers Recyling run worker instance #1\n',
    '2022-07-03T14:02:01.811Z workers Starting run worker instance #1\n',
    '2022-07-03T14:02:01.811Z workers Merging parallel test run results\n',
    '2022-07-03T14:02:01.813Z project Test run finished\n',
    '2022-07-03T14:02:01.814Z project Processed console.log entries\n',
    '2022-07-03T14:02:01.814Z project Processed loading sequences\n',
    '2022-07-03T14:02:01.814Z project Processed executed tests\n',
    '2022-07-03T14:02:01.816Z project Processed code coverage\n',
    '2022-07-03T14:02:01.825Z project Test run result processed and sent to IDE\n',
    '2022-07-03T14:02:02.069Z workers Started run worker instance (delayed) #0\n',
    '2022-07-03T14:02:02.088Z workers Started run worker instance (delayed) #1\n'
  ]
}
ArtemGovorov commented 2 years ago

Can you please share a sample repo demonstrating the issue (where ava CLI is running, but wallaby is not)? No real tests/source code is required, a copy of your project with all setup files and ./services/server/src/domain/metric/metric.spec with a dummy content like:

import test from 'ava';

test('foo', t => {
    t.pass();
});

should be enough for us to investigate.

keinsell commented 2 years ago

wallaby have problem the imports because errors are about these two packages.

import anyTest, { TestFn } from "ava";
import { faker } from "@faker-js/faker";

The rest of my test code looks like this.

import anyTest, { TestFn } from "ava";
import { faker } from "@faker-js/faker";

import { UserService } from "./user.service.js";
import { Prisma } from "prisma-client";
import { UserRepository } from "../../infrastructure/database/database.infra.js";

const test = anyTest as TestFn<{
  userCreationData: Prisma.UserCreateInput;
}>;

test.beforeEach(async (t) => {
  await UserRepository.deleteMany();

  t.context.userCreationData = {
    username: faker.internet.userName(),
    password: faker.internet.password(),
  };
});

// ! This is integration test which should be rewriten to Unit Test
test.serial("Should register new user", async (t) => {
  // Import UserService
  const userService = new UserService();

  // Create new User
  const user = await userService.registerUser({
    username: t.context.userCreationData.username,
    password: t.context.userCreationData.password,
  }); //??

  // Check if password of user is encrypted.
  t.true(
    user.user.password.startsWith("$argon2i$"),
    "Password should be encrypted."
  );

  // Should return JWT token of user
  t.is(
    typeof user.token,
    "string",
    "Should return jsonwebtoken of created user."
  );
});

// ! This is integration test which should be rewriten to Unit Test
test("Should login user", async (t) => {
  // Import UserService
  const userService = new UserService();

  // Create new User
  const user = await userService.registerUser({
    username: t.context.userCreationData.username,
    password: t.context.userCreationData.password,
  });

  // Login user
  const userLogin = await userService.loginUser({
    username: t.context.userCreationData.username,
    password: t.context.userCreationData.password,
  }); //??

  // Check if user is authenticated
  t.true(userLogin.isAuthenticated, "User should be authenticated.");
});
keinsell commented 2 years ago

Can I provide a same repository or I should really create a new one? I can make repository public later today so there will be source code available.

keinsell commented 2 years ago

My application will be open-source anyway, here you go: https://github.com/keinsell/neuronek/

ArtemGovorov commented 2 years ago

Thanks for providing the repo.

There are a couple of ways to adjust your config to make it work:

  1. Not sure what was the reason to set symlinkNodeModules: false in your Wallaby config, but if you update to the latest Wallaby core and set it to symlinkNodeModules: true, it should work for you with ESM loader.
  2. If you prefer to use CJS loader and not use symlinkNodeModules: true, then you may make the following changes:
module.exports = function (w) {
  return {

    ...

    files: [
      // { pattern: "package.json", load: true },
-     { pattern: "services/**/package.json", load: true },
+     { pattern: "services/**/package.json", ignore: true },
      { pattern: "services/**/src/**/*", load: true },
      { pattern: "services/**/src/**/*.spec.ts", ignore: true },

    ...

    compilers: {
      // "services/server/**/*.ts": w.compilers.typeScript({ module: "esnext" }),
      "**/*.ts": w.compilers.typeScript({
-       module: "esnext",
+       module: "commonjs",
        moduleResolution: "node",
        esModuleInterop: true,
      }),
    },
  };
};
keinsell commented 2 years ago

Configuration with commonjs works but there is still problem with ESM however, it's resolved for my actual needs. Thanks for help 😄

ArtemGovorov commented 2 years ago

Awesome, thanks for the update!