mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add package for sharing jest configuration for upcoming Features (#7198)
* Add package for shared jest configurations for Lens applications, Features and libraries. Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add root level script for running unit tests in monorepo mindset Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Ignore coverage files from VCS Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> --------- Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
114db72485
commit
73230c8659
11 files changed
+1902
-154
No files matched your search
@@ -0,0 +1,73 @@
|
||||
const path = require("path");
|
||||
const glob = require("glob");
|
||||
const { omit } = require("lodash/fp");
|
||||
|
||||
const getProjectColor = (projectNumber) => {
|
||||
const colors = [
|
||||
"red",
|
||||
"green",
|
||||
"yellow",
|
||||
"magenta",
|
||||
"cyan",
|
||||
"white",
|
||||
"redBright",
|
||||
"greenBright",
|
||||
"yellowBright",
|
||||
"blueBright",
|
||||
"magentaBright",
|
||||
"cyanBright",
|
||||
"whiteBright",
|
||||
];
|
||||
|
||||
return colors[projectNumber % colors.length];
|
||||
};
|
||||
|
||||
const nonMultiProjectConfigs = [
|
||||
"coverageDirectory",
|
||||
"coverageProvider",
|
||||
"coverageReporters",
|
||||
"collectCoverage",
|
||||
"collectCoverageFrom",
|
||||
"coveragePathIgnorePatterns",
|
||||
"coverageThreshold",
|
||||
];
|
||||
|
||||
const toJestMultiProjectConfig = (
|
||||
{ packageJson, jestConfig, packagePath },
|
||||
projectNumber
|
||||
) => ({
|
||||
rootDir: packagePath,
|
||||
|
||||
displayName: {
|
||||
name: packageJson.name,
|
||||
color: getProjectColor(projectNumber),
|
||||
},
|
||||
|
||||
...omit(nonMultiProjectConfigs, jestConfig),
|
||||
});
|
||||
|
||||
const getJestConfigsAndPackageJsons = (rootDir) => {
|
||||
const packageJsonPaths = glob
|
||||
.sync(`${rootDir}/packages/**/jest.config.js`, {
|
||||
ignore: "./**/node_modules/**/*",
|
||||
})
|
||||
.map((filePath) => path.dirname(filePath));
|
||||
|
||||
return packageJsonPaths.map((packagePath) => ({
|
||||
packagePath,
|
||||
packageJson: require(`${packagePath}/package.json`),
|
||||
jestConfig: require(`${packagePath}/jest.config.js`),
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = (rootDir) => ({
|
||||
projects: getJestConfigsAndPackageJsons(rootDir).map(
|
||||
toJestMultiProjectConfig
|
||||
),
|
||||
|
||||
watchPlugins: [
|
||||
"jest-watch-typeahead/filename",
|
||||
"jest-watch-typeahead/testname",
|
||||
"jest-watch-select-projects",
|
||||
],
|
||||
});
|
||||
Reference in new issue
Block a user