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
Allow to store wallaby config in subfolder and use relative paths in files and tests lists #68
Comments
At the moment wallaby config can only be placed in the root folder (equal or above tests and files). Thanks for the idea, changing project dir setting is a good option that we should support. |
And thanks for your note about |
|
+1 I too, would like to keep my config in a sub-directory. |
+1 |
+1 I would especially like this if it worked with the path for the test runner as well. |
Any news on this? |
@fvanwijk No news yet, I'll post some updates here when there's some news. |
one of the first things I ran into. |
I really would like this since I really want to keep the files in specific folders |
+1 |
I also put wallaby.js in the subfolder - just to make fast test some small small staff - don't want to change the main wallaby.js in the root. And got the next error: node_modules folder is one level up. jasmine installed. In the root project folder it works. Here is my config: |
@asnov You can try and use this approach and add this to your wallaby config in the subfolder: ...
var path = require('path');
process.env.NODE_PATH = path.join(__dirname, '..', 'node_modules');
...
If it's the only reason, then your other options is to just move your subfolder's wallaby config to the root by giving it a name different from your main wallaby config. |
Another vote for this. As others have said, given the amount of config files for webpack, babel, karma, and variants thereof for different environments or testing approaches, it's beneficial to get them out of the root dir. Also, if my whole team isn't using wallaby, I don't want to have to distract them with a file most don't need. |
+1 |
+1 |
I also have a use case where I want to provide a common config stored in a separate Node.js module. I can't set For now, the workaround is to symlink |
@boneskull In your case, wouldn't this work:
module.exports = require('my-wallaby-config/wallaby.config'); |
yes, thanks--that's another workaround, and I've had to do similar things for other tools. I was hoping to eliminate the boilerplate altogether--though reducing it is better than nothing! |
Are there any updates on this issue? Thanks. |
@kuechlerm Not at the moment, but I'll post an update here when there's some. |
@ArtemGovorov 3 years later, maybe it's time to make this a priority. |
+1 |
+1 Any updates on this? |
We don't have any update on this issue to share. Having said that, we are embarking on some big architectural changes to Wallaby in 2024 that may see this change. Our preferred approach (generally) is to try and automatically configure Wallaby for your project vs. requiring a configuration file, and so our efforts have been to push more in that direction. @jason-covington-auctane - I'm assuming Wallaby with automatic configuration does not work for your project? |
Correct, we recently moved over to Vite and Vitest from Webpacker and Jest. if I add the
|
@jason-covington-auctane - you should be able to completely remove your Wallaby configuration file and start Wallaby using the automatic configuration feature. |
I tried the following: const path = require("path")
module.exports = wallaby => { return {
localProjectDir: path.resolve(wallaby.localProjectDir, `..`),
compilers: {
"**/*.ts?(x)": wallaby.compilers.typeScript({
module: `CommonJS`
})
},
}} Sadly, from the dirty test of adding a console call as value, I think localProjectDir keeps its old value after the export. const path = require("path")
module.exports = wallaby => { return {
localProjectDir: console.debug(path.resolve(wallaby.localProjectDir, `..`)),
// ...
}} [Info] C:\coding\wallabyNotInRoot
[Info] Started Wallaby.js Core v1.0.1501
[Error] Looks like none of the paths specified in your files/tests list exist in C:\coding\wallabyNotInRoot\tools.
[Info] Wallaby App (realtime reports) is available at: http://localhost:51245
[Error] No files with tests found, check your tests list patterns.
[Info] Can't determine tests to run for the change, re-running all tests.
[Info] To prevent the full test run when can not determine tests to run, use `runAllTestsWhenNoAffectedTests: false` configuration option. |
@mikerouxfr - we're not entirely sure what you were attempting to configure, or whether it's something we currently support. The Wallaby configuration must be in your project root, and cannot reference files above your project root. If you have a specific configuration question, we'd be happy to help. If so, would you mind creating a new issue? |
I was trying to store Wallaby config in a subfolder and use relative paths in My post here was/is more to share about failed tentatives so other "googlers" can relate, or not spend time trying the same things, while adding more data/examples to this thread. My Jest config is within the Root folderInitial configuration working properly. Structure:
wallaby.js content: module.exports = wallaby => Object({
autoDetect: [`jest`],
compilers: {
"**/*.ts?(x)": wallaby.compilers.typeScript({
module: `CommonJS`
})
},
files: [
`./sources/**/*.ts`,
`./sources/*.ts`,
],
filesWithNoCoverageCalculated: [
`./sources/**/index.ts`,
],
name: `Awesome Calc`,
tests: [
`./tests/*.ts`,
],
}) Everything works as expected! Move wallaby conf to a subfolderStructure:
Updated wallaby.js content: module.exports = wallaby => Object({
autoDetect: [`jest`],
compilers: {
"**/*.ts?(x)": wallaby.compilers.typeScript({
module: `CommonJS`
})
},
files: [
`../sources/**/*.ts`,
`../sources/*.ts`,
],
filesWithNoCoverageCalculated: [
`../sources/**/index.ts`,
],
name: `Awesome Calc`,
tests: [
`../tests/*.ts`,
],
}) Console output:
Perhaps move the file without changing itI thought: as I open my editor at the project root, maybe not target the parent dir but still the current dir. Without moving the file, reverting the ".." to ".", I get this feedback in the console:
Add the runAllTests optionAdding the option mentioned in the last error message (
Seems the only difference is that the local web app does not start in this case. Tentative from my previous commentThen, reading the doc at wallabyjs.com/docs/config/overview, I figured I could try to hack a little and just override the value of So I tried changing the value of Here is the content of the wallaby.js along with the console output. const path = require(`path`)
module.exports = function(wallaby) {
console.debug(`localPjtDir before =>`, wallaby.localProjectDir)
wallaby.localProjectDir = path.resolve(wallaby.localProjectDir, `..`)
console.debug(`localPjtDir after =>`, wallaby.localProjectDir)
return {
autoDetect: [`jest`],
compilers: {
"**/*.ts?(x)": wallaby.compilers.typeScript({
module: `CommonJS`
})
},
files: [
`./sources/**/*.ts`,
`./sources/*.ts`,
],
localProjectDir: wallaby.localProjectDir,
name: `Awesome Calc`,
tests: [
`./tests/*.ts`,
],
}
}
Closing wordIf it is unrelated, sorry for posting here! It's the best thread I could find talking about "my issue". I can gladly open a new issue and attach a test project if needed. Let me know! Adding a quick question by the way: In my research, I could not find a way to set the Wallaby config within the package.json with a TS project. This would be a viable solution to me. To confirm I did not miss something important, is it possible? |
Thanks - I can tell you that it definitely is not supported. There are a number of non-trivial/fundamental changes that we would need to make to Wallaby to support this.
Since you are using What version of |
$ npm jest --version
8.13.2 Jest config from the package.json file: "jest": {
"preset": "ts-jest",
"moduleDirectories": [
"<rootDir>/node_modules",
"<rootDir>/sources"
],
"verbose": false
}, Makes me think I did not investigate Jest config much yet 🤔 |
To determine your jest version, use |
My bad 😇 $ npx jest --version
29.7.0 |
With your Wallaby/Jest configuration, Wallaby will ignore the I would think you can move all of your configuration to the Having said that, if |
True, it works! I haven't tried to delete it in some time. I started without a Wallaby file but end up creating one for some reason and never dared to remove it. So yes, for anyone who finds this post by searching, the solution suggested above is currently functioning! Thanks for the support and for the tools! |
My config is in
/tools/wallaby
and my specs are in/test/specs
. I cannot manage to let the message "No files with tests found, check your tests list patterns." disappear from the console. If I move the config file to the project root, everything works fine.I tried to prepend
"../../"
to my (test)file patterns, without result.Prepending
wallaby.localProjectDir + "/../../"
doesn't work either.Is it possible have the wallaby config in a subdir? I prefer to have the option to set the localProjectDir manually instead of always having the localProjectDir relative to the config file.
Side note: the
localProjectDir
on thewallaby
object does not end with a/
so it is unsuitable to just prepend it to your file paths.The text was updated successfully, but these errors were encountered: