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

TypeError: (0 , _loadBabelConfig.loadPartialConfigAsync) is not a function when loading test suites #28

Open
msakrejda opened this issue Oct 7, 2021 · 1 comment

Comments

@msakrejda
Copy link

When I run my tests, every suite fails with the "is not a function" error in the issue title. Here are the full details for one failure:

 FAIL  app/javascript/util/map.test.ts
  ● Test suite failed to run

    TypeError: (0 , _loadBabelConfig.loadPartialConfigAsync) is not a function

      at loadBabelConfigAsync (node_modules/babel-jest/build/index.js:197:73)
      at ScriptTransformer._getCacheKeyAsync (node_modules/@jest/transform/build/ScriptTransformer.js:313:37)
      at ScriptTransformer._getFileCachePathAsync (node_modules/@jest/transform/build/ScriptTransformer.js:357:33)
      at ScriptTransformer.transformSourceAsync (node_modules/@jest/transform/build/ScriptTransformer.js:637:38)
      at ScriptTransformer._transformAndBuildScriptAsync (node_modules/@jest/transform/build/ScriptTransformer.js:717:46)
      at ScriptTransformer.transformAsync (node_modules/@jest/transform/build/ScriptTransformer.js:789:25)

This is my jest config:

module.exports = {
  preset: 'vite-jest',
  testEnvironment: 'jsdom',
  globalSetup: './app/javascript/jestTestSetup',
  testMatch: [ "**/app/javascript/**/?(*.)+(spec|test).[jt]s?(x)" ],
  moduleDirectories: [ "node_modules", "app/javascript" ],
  moduleNameMapper: {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
    "\\.(css)$": "identity-obj-proxy",
  },
  transform: {
    "^.+\\.[t|j]sx?$": "babel-jest",
    "\\.(graphql)$": "<rootDir>/__mocks__/graphqlMock.js",
  },
};

Versions:

jest: 27.2.4
babel-jest: 27.2.4
vite-jest: 0.0.3

Any ideas?

@msakrejda
Copy link
Author

Digging into this a bit, I found that the problem was probably an outdated @babel/core. I updated it and then started getting an error similar to storybookjs/storybook#12893, but I followed the recommendation to remove node_modules and reinstall them, and that seems to have fixed things.

Should the deps be updated to require a recent-enough version? (I can track down what that version should be and submit a PR.)

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

1 participant