Closed madve2 closed 4 years ago
Can you confirm whether npx jest
works for you when you run it from the directory you have selected as your automatic configuration root (i.e. either <project directory>
, or the <custom directory>
you selected)?
If npx jest
does not work from the command line, then Wallaby automatic configuration will not work either. For Nx/Nrwl mono-repos, if you are using the default Jest runner, then the best first step is to ensure that npx jest
is working from the command-line in order to use Wallaby automatic configuration.
We tried to create an Angular Nx workspace that uses https://github.com/danguilherme/ng-cli-pug-loader but couldn't find instructions to configure and weren't sure how you then went on to configure jest.
Can you please provide us with instructions to create a similar workspace to yours or else provide us with a sample repo so we can see how everything is configured outside of Wallaby?
Thanks for the pointer. Indeed, while my tests work with ng test library-name
from the monorepo root, running npx jest
from the library folder fails. I'll try to fix that then, first, or create a sample repo with a minimal repro in case I get stuck.
I'll close this issue for now. If you have trouble or need assistance, you may respond to this issue and we can re-open, or else please create a new issue.
Hello again,
I got a bit stuck with this, unfortunately, so I have created a sample repo: https://github.com/madve2/nrwl-ng-pug
yarn install
(on Windows, probably you should run this and the following commands from WSL)npx ng test ng-pug-sample-lib
works (from the repo root)npx jest
from the library root (/libs/ng-pug-sample-lib
) fails, seemingly because of the Pug setup (which is referenced in the root jest.config.js
file and the postinstall
script in package.json
)I know this isn't fully Wallaby-specific at this point (other than the fact that I wouldn't mind npx jest
not working if I could make Wallaby somehow do what ng test
does :) ), but if you could help me find out what's wrong I'd greatly appreciate it. Thanks!
Thanks for the sample repo. We created a pull request to update your jest configuration to support running npx jest
and Wallaby from the project root.
Unfortunately there's still something wrong with the configuration that won't allow you to run Wallaby on a specific folder. We figured running on the project root would be OK but if you need it to run only on a specific lib/app, let us know and we'll take another look.
In terms of what we did to get everything working, we first applied the suggestion from our docs for how to run Wallaby on your entire Nx/Nrwl monorepo. After that, we still had some problems and had to update the jest configuration (which was pretty straight forward). The final challenge that we had was that Jest was now working from the command-line but ng test
no longer worked. We had to remove parts of the config by trial and error until we discovered what wasn't working and you will see in the base jest.config.js
in your repo root that we detect whether the configuration is being run from ng
or not.
Thanks for the PR, I'll try to apply it to our "main" project and get back to you 👍
Sorry I haven't been able to answer sooner, we have a huge workspace with a lot of projects, but during the past few days I was able to slowly update our configs and so far everything works well with your suggestions applied. I have also found that if I really want Wallaby to run only on a specific library/app, I can use the projects
key in the root jest.config
to specify which projects I want to test, and then run Wallaby from the project root.
Thanks again for your help with this, I'm so glad we were able to get it working in the end!
Issue description or question
We are using Angular CLI in an Nrwl monorepo with https://github.com/danguilherme/ng-cli-pug-loader.
Wallaby works with most of our libraries in automatic configuration mode (if we set "Root path" to the library root and manually add
module.exports.setupFilesAfterEnv = ['./src/test-setup.ts'];
to thejest.config.js
file for the library, because Nrwl sadly omits that), except for the ones containing components, because for those, Wallaby is unable to find (or process) the pug files.I tried creating a Wallaby config in various ways (e.g. using the autoDetect: true and trying to add pug loading below it, creating a wholly new config from scratch, etc.), but all my attempts failed for different reasons. The diagnostic report below came from the automatic configuration mode.
I think at the core of my issue might be the fact that Wallaby ignores / misunderstands this line in the jest config:
But maybe it's a completely different thing. Can you please help me with that?
Wallaby diagnostics report