Code Monkey home page Code Monkey logo

Comments (11)

axelchalon avatar axelchalon commented on May 18, 2024 2

yes, https://github.com/axelchalon/craco-issue

Notice how yarn start works but yarn test doesn't.

Some observations: tests work if there is only one test file, and tests work if I remove babel: {...} from the export of craco.config.js

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024 1

Thank you for your bug report and your solution, I will look into this before the end of the week!

from craco.

axelchalon avatar axelchalon commented on May 18, 2024 1

Hi! The test command doesn't seem to take the --react-scripts value into account:

craco test --react-scripts ../../node_modules/react-scripts

 FAIL  src/stores/sendStore.spec.js
  ● Test suite failed to run

    Cannot find module '/home/nicolas/www/fether/packages/fether-react/node_modules/react-scripts/config/paths.js'

craco {build,start} --react-scripts ../../node_modules/react-scripts both work fine though!

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024 1

It took a while but I finally found some time to work on this!

It was not an easy one.

I published an alpha version, if anyone can try it: https://www.npmjs.com/package/@craco/craco/v/4.0.0

The problem was that the --workspace, --scripts-version and --react-scripts options are provided by the CLI and the custom babel-jest transformer provided by craco doesn't have access to those options since the babel-jest transformer is called directly by Jest in another process.

The solution is to define those options in the craco.config.js file.

You can have a look here for the config: https://github.com/sharegate/craco/blob/add-paths-to-config-file/packages/craco/README.md#configuration-overview

Of course there is some drawback...

  • --workspace, --scripts-version and --react-scripts cannot be specified by the CLI anymore.
  • Custom location for the config file (--config) cannot be specified if you need to use craco support for babel-jest

@axelchalon @iamawebgeek

from craco.

axelchalon avatar axelchalon commented on May 18, 2024 1

Can confirm craco {test,build,start} all work fine with craco v4.0.0 and specifying reactScriptsPath in craco.config.js 👍 thank you!

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024

@teevik I will add a configuration value to facilitate the usage of workspace but in the meantime what you can do is:

craco start --react-scripts ../../../node_modules/react-scripts

from craco.

teevik avatar teevik commented on May 18, 2024

Alright, thank you so much!

from craco.

iamawebgeek avatar iamawebgeek commented on May 18, 2024

@axelchalon +1. passing --workspace flag did not help as well

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024

I will look into this as soon as possible. Thank you.

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024

@iamawebgeek @axelchalon could you provide a simple repository that reproduce the case?

It works fine with my sandbox project with either the --workspace flag or a custom --react-scripts path

"test": "craco test --verbose --workspace",
"test-react-scripts": "craco test --verbose --react-scripts ../../node_modules/react-scripts-custom"

Thank you

from craco.

patricklafrance avatar patricklafrance commented on May 18, 2024

Thank you @axelchalon

Oh that explains why, my sandbox project contains a single test file.

from craco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.