mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
fix collecting coverage for jest tests
This commit is contained in:
15
scm-ui/jest-preset/src/findName.js
Normal file
15
scm-ui/jest-preset/src/findName.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
function findName(directory) {
|
||||
const packageJSON = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), {encoding: "UTF-8"}));
|
||||
|
||||
let name = packageJSON.name;
|
||||
const orgaIndex = name.indexOf("/");
|
||||
if (orgaIndex > 0) {
|
||||
return name.substring(orgaIndex + 1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
module.exports = findName;
|
||||
16
scm-ui/jest-preset/src/findTarget.js
Normal file
16
scm-ui/jest-preset/src/findTarget.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
function findMavenModuleRoot(directory) {
|
||||
if (fs.existsSync(path.join(directory, "pom.xml"))) {
|
||||
return directory;
|
||||
}
|
||||
return findMavenModuleRoot(path.resolve(directory, ".."));
|
||||
}
|
||||
|
||||
function findTarget(directory) {
|
||||
const moduleRoot = findMavenModuleRoot(directory);
|
||||
return path.join(moduleRoot, "target");
|
||||
}
|
||||
|
||||
module.exports = findTarget;
|
||||
@@ -1,10 +1,13 @@
|
||||
const { createTransformer } = require("babel-jest");
|
||||
const transformer = createTransformer({
|
||||
const babelJest = require("babel-jest");
|
||||
const transformer = babelJest.createTransformer({
|
||||
presets: ["@scm-manager/babel-preset"],
|
||||
plugins: ["require-context-hook"]
|
||||
plugins: ["require-context-hook"],
|
||||
babelrc: false,
|
||||
configFile: false
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
...transformer,
|
||||
process(src, filename) {
|
||||
if (
|
||||
!filename.includes("node_modules") ||
|
||||
|
||||
Reference in New Issue
Block a user