Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find any Jest runner configuration in '.' with PNPM #3277

Open
BrandonALittle opened this issue Oct 5, 2023 · 3 comments
Open

Cannot find any Jest runner configuration in '.' with PNPM #3277

BrandonALittle opened this issue Oct 5, 2023 · 3 comments
Assignees

Comments

@BrandonALittle
Copy link

BrandonALittle commented Oct 5, 2023

Issue description or question

I read that Wallaby supports PNPM out of the box, but I'm not having success getting it running. I suspect this may be due to PNPM overrides, but I'm not sure. I am attempting automatic configuration.

My jest.config.js in the root:

module.exports = {
  collectCoverageFrom: [
    '**/pages/**/*.{js,jsx,ts,tsx}',
    '**/src/**/*.{js,jsx,ts,tsx}',
    '!**/*.d.ts',
    '!**/node_modules/**',
    '!**/.next/**',
  ],
  coverageReporters: ['json', 'lcov', 'clover'],
  moduleDirectories: ['node_modules', '<rootDir>'],
  moduleNameMapper: {
    /* Handle CSS imports (with CSS modules)
    https://jestjs.io/docs/webpack#mocking-css-modules */
    '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',

    // Handle CSS imports (without CSS modules)
    '^.+\\.(css|sass|scss)$': '<rootDir>/src/libs/test/mocks/style.ts',

    /* Handle image imports
    https://jestjs.io/docs/webpack#handling-static-assets */
    '^.+\\.(jpg|jpeg|png|gif|webp|avif|svg)$':
      '<rootDir>/src/libs/test/mocks/file.ts',
  },
  // Send results to Test Analytics
  reporters: ['default'],

  setupFilesAfterEnv: ['<rootDir>/jest/jest.setup.ts'],
  testPathIgnorePatterns: [
    '<rootDir>/node_modules/',
    '<rootDir>/.next/',
    '<rootDir>/public/',
  ],
  testEnvironment: 'jsdom',

  // Enable column + line capture for Test Analytics
  testLocationInResults: true,

  transform: {
    '^.+\\.(js|jsx|ts|tsx)$': [
      '@swc/jest',
      {
        jsc: {
          parser: {
            syntax: 'typescript',
            tsx: true,
          },
          transform: {
            react: {
              runtime: 'automatic',
            },
          },
        },
      },
    ],
    '^.+\\.(ttf|svg|png|jpg|gif)$': `${__dirname}/jest/staticAssetMock.js`,
  },
  transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss)$'],
  testTimeout: 20000,
}

PNPM overrides (in package.json):

"pnpm": {
    "overrides": {
      ...
      "@jest/core": "npm:@rwx-research/jest-core@29.5.3",
      "jest-config": "npm:@rwx-research/jest-config@29.5.3",
      "jest-runner": "npm:@rwx-research/jest-runner@29.5.3",
      "jest-circus": "npm:@rwx-research/jest-circus@29.5.3"
    }
  }

When I attempt to copy the diagnostics report (in VSCODE), there is no command to do so.
The command was not easy to find, but must be something with VSCODE.

Wallaby diagnostics report

{
  editorVersion: '1.82.2',
  pluginVersion: '1.0.371',
  editorType: 'VSCode',
  osVersion: 'darwin 22.6.0',
  nodeVersion: 'v18.18.0',
  coreVersion: '1.0.1475',
  checksum: 'NjZkMTUyYWRjMWM3YWU1OGNhYTk0NzFjNmYwYTBlNmIsMTcyODc3NzYwMDAwMCww',
  config: { tests: [], files: [] },
  packageJSON: {
    dependencies: {
      '@beam-tech/analytics': '^1.3.28',
      '@beam-tech/api': '^9.1.147',
      '@beam-tech/authz-client': '^1.1.11',
      '@beam-tech/datetime': '^1.1.16',
      '@beam-tech/icons': '^1.0.0',
      '@beam-tech/link': '^1.2.1',
      '@beam-tech/react-hooks': '^5.0.4',
      '@beam-tech/ui': '^15.3.0',
      '@beam-tech/url': '3.5.22',
      '@googlemaps/js-api-loader': '1.15.2',
      '@radix-ui/react-select': '^1.2.2',
      '@radix-ui/react-switch': '^1.0.3',
      '@radix-ui/react-tabs': '^1.0.4',
      'camelcase-keys': '^9.1.0',
      'date-fns': '^2.30.0',
      'isomorphic-fetch': '^3.0.0',
      'lodash.camelcase': '^4.3.0',
      'lodash.clonedeep': '^4.5.0',
      'lodash.delay': '^4.1.1',
      'lodash.differenceby': '^4.8.0',
      'lodash.get': '^4.4.2',
      'lodash.groupby': '^4.6.0',
      'lodash.has': '^4.5.2',
      'lodash.isequal': '^4.5.0',
      'lodash.isfunction': '^3.0.9',
      'lodash.isplainobject': '^4.0.6',
      'lodash.lowercase': '^4.3.0',
      'lodash.mapvalues': '^4.6.0',
      'lodash.merge': '^4.6.2',
      'lodash.mergewith': '^4.6.2',
      'lodash.noop': '^3.0.1',
      'lodash.omit': '^4.5.0',
      'lodash.omitby': '^4.6.0',
      'lodash.pick': '^4.4.0',
      'lodash.setwith': '^4.3.2',
      'lodash.snakecase': '^4.1.1',
      'lodash.sortby': '^4.7.0',
      'lodash.startcase': '^4.4.0',
      'lodash.uniq': '^4.5.0',
      'lodash.uniqby': '^4.7.0',
      'lodash.uniqwith': '^4.5.0',
      'lodash.update': '^4.10.2',
      'lodash.upperfirst': '^4.3.1',
      next: '13.5.4',
      'next-fonts': '^1.5.1',
      numeral: '^2.0.6',
      'object-hash': '^3.0.0',
      prettier: '^3.0.3',
      'rc-tooltip': '^6.1.0',
      react: '^18.2.0',
      'react-cookie': '^6.1.1',
      'react-dom': '^18.2.0',
      'react-dropzone': '^14.2.3',
      'react-is': '^18.2.0',
      'react-signature-canvas': '^1.0.6',
      'round-half-even': '^1.3.0',
      'sanitize-html': '^2.11.0',
      sharp: '^0.32.5',
      'snakecase-keys': '^5.4.7',
      'styled-components': '^5.3.11',
      swr: '^1.3.0',
      'type-fest': '^4.3.3',
      uuid: '^9.0.1',
      yup: '^0.32.11'
    },
    devDependencies: {
      '@beam-tech/danger-shared-rules-plugin': '^1.5.2',
      '@beam-tech/eslint-plugin': '^3.1.19',
      '@jest/core': 'npm:@rwx-research/jest-core@^29.5.3',
      '@pact-foundation/pact': '^12.1.0',
      '@pact-foundation/pact-node': '^10.17.7',
      '@seadub/danger-plugin-eslint': '^3.0.2',
      '@swc/core': '^1.3.92',
      '@swc/jest': '^0.2.29',
      '@testing-library/jest-dom': '^6.1.3',
      '@testing-library/react': '^14.0.0',
      '@testing-library/react-hooks': '^8.0.1',
      '@testing-library/user-event': '^14.5.1',
      '@types/gtag.js': '^0.0.13',
      '@types/jest': '^29.5.5',
      '@types/lodash.camelcase': '^4.3.7',
      '@types/lodash.clonedeep': '^4.5.7',
      '@types/lodash.delay': '^4.1.7',
      '@types/lodash.differenceby': '^4.8.7',
      '@types/lodash.get': '^4.4.7',
      '@types/lodash.groupby': '^4.6.7',
      '@types/lodash.has': '^4.5.7',
      '@types/lodash.isequal': '^4.5.6',
      '@types/lodash.isfunction': '^3.0.7',
      '@types/lodash.isplainobject': '^4.0.7',
      '@types/lodash.lowercase': '^4.3.7',
      '@types/lodash.mapvalues': '^4.6.7',
      '@types/lodash.merge': '^4.6.7',
      '@types/lodash.mergewith': '^4.6.7',
      '@types/lodash.noop': '^3.0.7',
      '@types/lodash.omit': '^4.5.7',
      '@types/lodash.omitby': '^4.6.7',
      '@types/lodash.pick': '^4.4.7',
      '@types/lodash.setwith': '^4.3.7',
      '@types/lodash.snakecase': '^4.1.7',
      '@types/lodash.sortby': '4.7.7',
      '@types/lodash.startcase': '^4.4.7',
      '@types/lodash.times': '^4.3.7',
      '@types/lodash.uniq': '^4.5.7',
      '@types/lodash.uniqby': '^4.7.7',
      '@types/lodash.uniqwith': '^4.5.7',
      '@types/lodash.update': '^4.10.7',
      '@types/lodash.upperfirst': '^4.3.7',
      '@types/node': '^20.8.2',
      '@types/numeral': '^2.0.3',
      '@types/object-hash': '^3.0.4',
      '@types/react': '^18.2.25',
      '@types/react-signature-canvas': '^1.0.3',
      '@types/sanitize-html': '^2.9.1',
      '@types/styled-components': '^5.1.28',
      '@types/testing-library__jest-dom': '^5.14.9',
      '@types/uuid': '^9.0.4',
      '@typescript-eslint/eslint-plugin': '^5.62.0',
      '@typescript-eslint/parser': '^5.62.0',
      'buildkite-test-collector': '^1.5.0',
      coveralls: '^3.1.1',
      danger: '^11.3.0',
      eslint: '^8.50.0',
      'eslint-config-next': '^12.3.4',
      'eslint-config-prettier': '^8.10.0',
      'eslint-plugin-fp': '^2.3.0',
      'eslint-plugin-import': '^2.28.1',
      'eslint-plugin-jest': '^27.4.0',
      'eslint-plugin-jest-dom': '^4.0.3',
      'eslint-plugin-jsx-a11y': '^6.7.1',
      'eslint-plugin-no-unsanitized': '^4.0.2',
      'eslint-plugin-no-wildcard-postmessage': '^0.2.0',
      'eslint-plugin-prettier': '^5.0.0',
      'eslint-plugin-prototype-pollution-security-rules': '^1.0.6',
      'eslint-plugin-react': '^7.33.2',
      'eslint-plugin-react-hooks': '^4.6.0',
      'eslint-plugin-scanjs-rules': '^0.2.1',
      'eslint-plugin-security': '^1.7.1',
      'eslint-plugin-security-node': '^1.1.1',
      'eslint-plugin-segment-security': '^0.9.0',
      'eslint-plugin-testing-library': '^5.11.1',
      'identity-obj-proxy': '^3.0.0',
      jest: '29.7.0',
      'jest-circus': 'npm:@rwx-research/jest-circus@^29.5.3',
      'jest-config': 'npm:@rwx-research/jest-config@^29.5.3',
      'jest-environment-jsdom': '29.7.0',
      'jest-fail-on-console': '^3.1.1',
      'jest-mock': '^29.7.0',
      'jest-pact': '^0.11.0',
      'jest-runner': 'npm:@rwx-research/jest-runner@^29.5.3',
      'lint-staged': '13.3.0',
      'lodash.times': '^4.3.2',
      miragejs: '^0.1.47',
      'next-logger': '^3.0.2',
      'next-router-mock': '^0.9.9',
      prettier: '^3.0.3',
      'react-test-renderer': '^18.2.0',
      'type-fest': '^4.3.2',
      typescript: '^5.2.2',
      'universal-cookie': '^6.1.1',
      webpack: '^5.88.2'
    }
  },
  fs: { numberOfFiles: 0 },
  debug: [
    '2023-10-05T19:26:12.471Z project waiting for initial run signal\n',
    '2023-10-05T19:26:12.477Z config Attempting automatic configuration for angular\n',
    '2023-10-05T19:26:12.478Z angular/cli config Angular CLI not found.\n',
    '2023-10-05T19:26:12.478Z config Finished attempting automatic configuration for angular (1ms)\n',
    '2023-10-05T19:26:12.478Z config Attempting automatic configuration for jest\n',
    "2023-10-05T19:26:12.528Z jest/config Error: Can not find any Jest runner configurations in '<homeDir>/Documents/beam/beam-frontend'.\n" +
      '    at Object.loadJest (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:496:2358)\n' +
      '    at async n (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:184:23331)\n' +
      '    at async Object.configure (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:184:26443)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:132:12007)\n' +
      '    at async automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:132:11892)\n' +
      '    at async Config.load (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:132:11832)\n',
    '2023-10-05T19:26:12.528Z config Finished attempting automatic configuration for jest (50ms)\n',
    '2023-10-05T19:26:12.528Z config Attempting automatic configuration for vitest\n',
    '2023-10-05T19:26:12.528Z vitest/config Error: Vitest dependency not found.\n' +
      '    at Object.configure (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:185:1496)\n' +
      '    at automaticConfigurationProviders.reduce.Promise.resolve.success (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:132:12015)\n' +
      '    at async Config.load (<homeDir>/.vscode/extensions/wallabyjs.wallaby-vscode-1.0.371/wallaby2fe572/server.js:132:11832)\n',
    '2023-10-05T19:26:12.528Z config Finished attempting automatic configuration for vitest (0ms)\n'
  ]
}
@smcenlly smcenlly self-assigned this Oct 6, 2023
@smcenlly
Copy link
Member

smcenlly commented Oct 6, 2023

It looks like you may have some customised jest packages, is that correct?

We were able to reproduce your issue using the package.json below:

{
  "name": "wallaby-3277",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
  },
  "devDependencies": {
    "@jest/core": "npm:@rwx-research/jest-core@^29.5.3",
    "@swc/core": "^1.3.92",
    "@swc/jest": "^0.2.29",
    "jest": "29.7.0",
    "jest-circus": "npm:@rwx-research/jest-circus@^29.5.3",
    "jest-config": "npm:@rwx-research/jest-config@^29.5.3",
    "jest-environment-jsdom": "29.7.0",
    "jest-fail-on-console": "^3.1.1",
    "jest-mock": "^29.7.0",
    "jest-pact": "^0.11.0",
    "jest-runner": "npm:@rwx-research/jest-runner@^29.5.3"
  }, "pnpm": {
    "overrides": {
      "@jest/core": "npm:@rwx-research/jest-core@29.5.3",
      "jest-config": "npm:@rwx-research/jest-config@29.5.3",
      "jest-runner": "npm:@rwx-research/jest-runner@29.5.3",
      "jest-circus": "npm:@rwx-research/jest-circus@29.5.3"
    }
  }
}

When we updated to use the official jest packages, everything works for us (with pnpm overrides):

{
  "name": "wallaby-3277",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
  },
  "devDependencies": {
    "@jest/core": "npm:@jest/core@^29.5.0",
    "@swc/core": "^1.3.92",
    "@swc/jest": "^0.2.29",
    "jest": "29.7.0",
    "jest-circus": "npm:jest-circus@^29.5.0",
    "jest-config": "npm:jest-config@^29.5.0",
    "jest-environment-jsdom": "29.7.0",
    "jest-fail-on-console": "^3.1.1",
    "jest-mock": "^29.7.0",
    "jest-pact": "^0.11.0",
    "jest-runner": "npm:jest-runner@^29.5.0"
  }, "pnpm": {
    "overrides": {
      "@jest/core": "npm:@jest/core@29.5.0",
      "jest-config": "npm:jest-config@29.5.0",
      "jest-runner": "npm:jest-runner@29.5.0",
      "jest-circus": "npm:jest-circus@29.5.0"
    }
  }
}

What we can see happening in the internals of Wallaby is that our call to jest to return your project configuration is returning an empty configuration object.

I'm not sure what changes have been made to your custom packages; it's possible that the changes are not compatible with Wallaby's support for jest's production build.

Wallaby has a number of integration points for the various testing frameworks that we support, including on-the-fly in-memory patching of some npm module file content as it is read from disk at runtime. It's also possible that when using your custom packages (looks like on disk it's @rwx-research+jest*) our integration points are not being correctly applied.

If you can provide us with access to the @rwx-research/jest modifications, we could quickly check if there are breaking changes made to your files for the integration. Otherwise, I expect the problem is incompatible paths between jest's packages and your custom packages. Unfortunately I don't think we can easily support a custom build of jest's modules.

@BrandonALittle
Copy link
Author

Thanks for digging into this! I've done more digging on my side as well. I'm ten days new to this codebase, and have never heard of ABQ before: https://github.com/rwx-research/abq, which is where this configuration is coming from: https://www.rwx.com/docs/abq/test-frameworks/jest#using-pnpm. The problem is easily solved by removing the overrides configuration object from package.json, and re-installing my packages. However, that's not going to work for my larger org and can't be checked in to version control. ABQ is being used to speed up CI pipelines and save $.

I can manage this a couple of ways locally, but it would be outstanding if I could just configure wallaby to work with this config. I totally understand you can't support a custom build of jest's modules, however. Please share any thoughts you might have. Thanks!

@smcenlly
Copy link
Member

smcenlly commented Oct 6, 2023

Unfortunately we don't have a good solution for you in this space, besides adding first class support for abq with the various testing frameworks it supports.

Happy to repurpose this issue as a feature request to add support if you like?

Looking at npm trends, the @rwx-research/jest-core usage numbers are quite low (about 0.03% of jest), and so not something we can justify adding support for at the moment, but we are happy to monitor and reconsider if/when that changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants