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

Integration with CRACO #240

Open
SnapeEye opened this issue Sep 13, 2022 · 3 comments
Open

Integration with CRACO #240

SnapeEye opened this issue Sep 13, 2022 · 3 comments

Comments

@SnapeEye
Copy link

Hey!

Faced a problem when tried to add this plugin in CRACO project. Jest test runner is used.
What I did:

  • added new setup file for jest (the file is used by jest, inserted log to verify it):
module.exports = {
  jest: {
    configure: (jestConfig, { env, paths, resolve, rootDir }) => {
      if (!jestConfig.setupFiles) {
        jestConfig.setupFiles = [`${rootDir}\\jestGlobalSetup.js`]
      } else {
        jestConfig.setupFiles.push(`${rootDir}\\jestGlobalSetup.js`)
      }
      return jestConfig
    },
  },
}
  • added require for plugin to integrate (tried all the 3 ways - no result):
 require('babel-register')({
   plugins: ['babel-plugin-rewire'],
})
// require('babel-core').transform('code', { plugins: ['babel-plugin-rewire'] })
// require('babel-core').transform('code', { plugins: ['rewire'] })

So when I run tests, I expect the following code to be valid:

import { __RewireAPI__ as RWA } from '../logic'
import { __Rewire__ as RW } from '../logic'
console.log(RWA)
console.log(RW)

Tried different naming, thought maybe smth changed. But got undefined for both.

Maybe someone will advice what can be done? Or explain why it is not working. Or where I messed up -_-
Will appreciate any help, comments, explanations, etc.

@SnapeEye
Copy link
Author

ping

2 similar comments
@SnapeEye
Copy link
Author

SnapeEye commented Oct 4, 2022

ping

@SnapeEye
Copy link
Author

ping

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