-
Notifications
You must be signed in to change notification settings - Fork 45
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
lerna 4 yarn 2, not resolving correctly #2733
Comments
Are you able to share a sample repo of your project structure/setup? We need to know about your project structure, jest setup, etc. in order to try work out what's going on. |
Thank you as always for helping @smcenlly ! I don't have a way to share the project (it's work), but I can probably provide more setup/config files. Would that help? (This yarn adaptation has been war) |
Yes, please provide all the configuration files ( |
@smcenlly I've updated all that I can think of within the original comment above. I've added the project layout And I just "pretty up" the pieces above... |
@kvernon - we're not especially familiar with yarn2 and lerna running together and haven't been able to get it to work for us. We kept getting:
as mentioned here: lerna/lerna#2449 Instead, we set up a similar yarn2 project that had almost the same configuration but everything was working for us. Could you please:
|
ya, I'm new with it too. You actually run Also, I'll see what I can do. It'll take a few days. They just the me on a last minute project Also, you should be able to run |
Howdy @smcenlly I was able to put this together: https://github.com/kvernon/wallaby-lerna4-yarn2/tree/master
|
@kvernon - thanks for providing the sample repo. I wasn't expecting to see Can you see if this configuration is working for you? wallaby.js module.exports = () => ({
autoDetect: true,
files: [
'!**/packages/tests/integration/**/*',
{ pattern: 'node_modules/@company/**', ignore: true }
],
tests: [
'**/tests/unit/**/*.test.*',
{ pattern: 'node_modules/@company/**', ignore: true }
],
testFramework: {
// the jest configuration file path
// (relative to project root)
configFile: './jest.config.js'
},
debug: true
}); We're still not entirely sure why jest is working from the command-line and not from Wallaby so I am still investigating that but the configuration above seems to work for us. |
It looks like there are still a few other problems; coverage indicators and inline value display isn't working properly. It looks like in the context of Wallaby running (at least, - we're not sure if this also affects jest), Wallaby may be using the code from |
Thanks again for the sample repo, it really helped diagnose what was going on. There were two issues:
To fix this, you need to update {
"extends": "./tsconfig.build.json",
"compilerOptions": {
+ "sourceMap": true,
"baseUrl": ".",
"paths": {
"@company/*": ["packages/*/lib"]
},
}
}
There are a few ways you can fix this: Wallaby.js - provide a complete files/tests configuration: module.exports = () => ({
autoDetect: true,
// provide files[] and tests[] patterns to match all required source/tests for project
files: [
'packages/**',
'!packages/**/tests/**',
],
tests: [
'packages/**/tests/unit/**/?(*.)+(spec|test).[jt]s?(x)',
],
testFramework: {
configFile: './jest.config.js'
}
}); Wallaby.js - override autoDetect configuration to adjust files/tests: module.exports = () => ({
autoDetect: true,
// override tests to exclude integration tests that run using jest without wallaby
tests: {
override: (testPatterns) => {
testPatterns.push('!**/packages/tests/integration/**/*');
return testPatterns;
}
},
testFramework: {
configFile: './jest.config.js'
}
}); Wallaby.js - override autoDetect configuration to use a different module.exports = () => ({
autoDetect: true,
// use a separate jest configuration file that extends from base configuration but excludes
// additional files (e.g. integration tests)
testFramework: {
configFile: './jest.wallaby.config.js'
}
}); |
Thank you, @smcenlly, for helping me with this. I'll report later today over how this goes. I do have one |
@smcenlly I applied the changes to repo -- they work for that issue. For the next part tho, yea, but this should be the last part. I have issues with When you pull latest, you'll see I added coverage that restricts files. I added notes to the readme as well. The problem is this. We have to restrict coverage in jest, when I apply this with jest, it works, however, wallabjs is dead in the water when I tell it to avoid files.
collectCoverageFrom: [
'!**/tests/integration/**',
'!**/**/.eslintrc.js',
'!**/**/jest.config.js',
'!**/**/jest.integration.config.js',
] pretty common stuff to not include for test coverage. How do I get wallabjs to work with this information applied? from the branch, when you run |
Also, I was reviewing this again (before the branch update I did), and I noticed that the coverage was not updated with it as well. Like the tests passed, and there were boxes on the tests, but the file doesn't have boxes (red/green/gray) indicating coverage. |
If you set the jest.unit.preset.js ...
collectCoverageFrom: [
+ '**/*.ts',
'!**/tests/integration/**',
'!**/**/.eslintrc.js',
'!**/**/jest.config.js',
'!**/**/jest.integration.config.js',
],
...
This may be a bug in Wallaby; we'll do some investigation and let you know. |
I just tested this in your sample repo and Wallaby does not run tests in the |
Howdy @smcenlly, When I add
|
I reviewed your repo and it seems that you updated
I have sent you a pull request for your repo with everything working (also available in our fork of your repo). |
@smcenlly thank you for looking at this. TL;DRI applied the change and it works. Longer:So, I honestly don't know how to go forward. This change works, but this exact same setup applied fails I've done:
Result on my actual project:I get integration tests that attempt run that are outside of the jest.config project scope |
@smcenlly OK, I think I've got the issue around why the autoconfig could easily happen: https://github.com/kvernon/wallaby-lerna4-yarn2/tree/feature/exclusion in this:
Results
Wallaby Console:
|
Ooooh, @smcenlly , I think I may know what's going on with the integration tests. So in the wallabyjs (same simple config you supplied), we ignore the integration tests, however they still load, which leaves the idea of doing something like: example 1: module.exports = () => ({
autoDetect: true,
files: [
'!packages/*/tests/integration/**/*.ts'
],
debug: true,
trace: true
}); example 2: module.exports = () => ({
autoDetect: true,
files: [
{ pattern: 'packages/*/tests/integration/*.ts', hideFromErrorStackTrace: true, instrument: false, load: false },
{ pattern: 'packages/*/tests/integration/**/*.ts', hideFromErrorStackTrace: true, instrument: false, load: false }
],
debug: true,
trace: true
}) However every time I try to get it to NOT load those files, I still see the same error of:
So, I got questions!
and thank you and your team with all your help on this again! |
Thanks for updating the sample repo with the new branch. We can see what this is happening now. We had understood from your previous message that each Unlike Jest, when Wallaby runs your jest tests, Wallaby merges your various jest configurations and runs on all jest projects together at the same time. There are a few things that matter with Wallaby that don't matter so much with Jest (certainly not with a. Dependencies should be the same version (or you may run into some weird issues). (b) is causing a problem in your case. Your testMatch: ['**/unit/**/?(*.)+(spec|test).[jt]s?(x)'], But your testMatch: ['**/tests/**/?(*.)+(spec|test).[jt]s?(x)'], When Wallaby unions the testMatch patterns, it tries to find tests for all projects based on: testMatch: [
'**/unit/**/?(*.)+(spec|test).[jt]s?(x)', // or
'**/tests/**/?(*.)+(spec|test).[jt]s?(x)'
], When the There are a couple of ways you can fix this: 1. Ensure testMatch patterns are consistent across all projects. 2. Ensure testMatch patterns that are overridden have enough context to specify project name, for example ( const packageFile = require('./package.json');
const preset = require('../../jest.unit.preset');
delete preset.testMatch;
delete preset.globals;
delete preset.transform;
delete preset.coverageThreshold;
module.exports = {
...preset,
testMatch: ['**/npm-scripts/tests/**/?(*.)+(spec|test).[jt]s?(x)'],
displayName: packageFile.name,
coverageDirectory: `../../coverage/packages/${packageFile.name}`
}; 3. Override with a Wallaby configuration file to exclude integration tests for all projects ( module.exports = () => ({
autoDetect: true,
// override tests to exclude integration tests that run using jest without wallaby
tests: {
override: (testPatterns) => {
testPatterns.push('!packages/**/tests/integration/**/?(*.)+(spec|test).[jt]s?(x)');
return testPatterns;
}
},
testFramework: {
configFile: './jest.config.js'
}
}); Please make sure that you only apply one of the fixes as applying multiple at the same time, may cause other test selection problems. Regarding your questions:
Since you have overridden the
See the example in (3) above. You can add additional patterns to be project specific if you need (instead of using the |
Thank you again, @smcenlly. I did the test object override, and it looks like it did the job. I suppose the only thing that really comes from this is documenting the overrides for tests? I went here, https://wallabyjs.com/docs/config/files.html and there is no information on how to override and when to array vs object for tests. Again, this is great! thank you and your team again with your time in helping me. |
Lerna@4 and Yarn@2 (berry) + Wallabyjs not Playing nice
Howdy crew at WallabyJs,
You've all helped me in the past with great ease. and I'm hoping the same will hold true this time. I've taken your advice over setting up NX and also had it applied to Lerna with NPM (thank you for your help again).
My issue is that we're transitioning to from NPM 6x to Yarn 2.
First of all, I've followed these strategies:
Yarn2: https://wallabyjs.com/docs/integration/yarn2.html
Reference to jest.config help: #2657 (comment)
First my wallaby setup:
I've got an isolated config like so:
I get a long list of items where it tries to use the import statement outside of the module (from failing tests log tab in Webstorm):
package.json
Now if run this using from the above using:
> yarn run test:root
I have everything running as a successful scenario directly from CLIWallaby diagnostics report
lerna.json
the project structure is as follows:
each
packages/**package.json
is forscripts
and*dependencies
:each
packages/**/jest.config.js
the same:each
packages/**/tsconfig.build.json
is the same:each
packages/**/tsconfig.json
is similar (this one is for core-sdk):The key difference in each one is the
references
area<root>/jest.unit.preset.js
<root>/tsconfig.json
<root>/tsconfig.build.json
The text was updated successfully, but these errors were encountered: