Closed pastor3llo closed 5 years ago
How are you running the tests?
i just took the repo as is and i did: $ yarn $ cd ~/repos/cra-workspaces-poc/apps create-react-app --scripts-version @f1lt3r/react-scripts@2.1.1-workspaces-04 app-foo $ cd ~/repos/cra-workspaces-poc/apps/app-foo yarn start was ok, but on $ yarn test
and i got: ` FAIL src/App.test.js ● Test suite failed to run
Cannot find module '@project/comp-one' from 'App.js'
2 | import logo from './logo.svg';
3 | import './App.css';
> 4 | import CompOne from '@project/comp-one';
| ^
5 |
6 | class App extends Component {
7 | render() {
at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:221:17)
at Object.<anonymous> (src/App.js:4:1)
Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 1.427s Ran all test suites.
Watch Usage › Press f to run only failed tests. › Press o to only run tests related to changed files. › Press q to quit watch mode. › Press t to filter by a test name regex pattern. › Press p to filter by a filename regex pattern. › Press Enter to trigger a test run.`
I have experienced the same behaviour both with my own monorepo and a clone of this one.
@F1LT3R this is a really big hurdle to me using this approach on my codebase. Is there anything I can do to help fix it?
Should be working now @Remimstr @pastor3llo you want to checkout and test?
Unfortunately no, it's still not working. I did exactly the steps as you outlined for a new repo:
git clone git@github.com:react-workspaces/cra-workspaces-playground.git
cd cra-workspaces-playground
yarn
cd packages/apps/app-one
yarn test
and it still gives the same "Cannot find module '@project/comp-one' from 'App.js' error.
In case it's relevant, I'm using node v11.5.0 yarn v1.15.2 and npm v6.4.1
Working here...
You might need to pull this repo and try that way.
I think following the steps there are parts missing that would make testing work for you.
@Remimstr try adding "main": "src/index.js"
to each package.json
.
That suggestion fixed it for me. Thank you for the help!
I tried the stuff in this repo but i found that yarn test is not working ` Test suite failed to run
Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 2.451s`