mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-05 03:40:56 +01:00
fix tests for core plugins
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
"version": "2.0.0-SNAPSHOT",
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"build": "webpack --mode=development"
|
||||
"build": "webpack --mode=development",
|
||||
"test": "jest --config=../../scm-ui/scripts/jest-plugin.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"flow-bin": "^0.109.0",
|
||||
@@ -11,7 +12,7 @@
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.js$": "../../scm-ui/scripts/babelMonoRepoTransformer.js"
|
||||
"^.+\\.js$": "../../scm-ui/scripts/babelPluginTransformer.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import RepositoryConfig from "./RepositoryConfig";
|
||||
|
||||
// @visibleForTesting
|
||||
export const gitPredicate = (props: Object) => {
|
||||
return props.repository && props.repository.type === "git";
|
||||
return !!(props && props.repository && props.repository.type === "git");
|
||||
};
|
||||
|
||||
binder.bind(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import { gitPredicate } from "./index";
|
||||
|
||||
describe("test gi predicate", () => {
|
||||
describe("test git predicate", () => {
|
||||
it("should return false", () => {
|
||||
expect(gitPredicate()).toBe(false);
|
||||
expect(gitPredicate({})).toBe(false);
|
||||
@@ -10,6 +10,6 @@ describe("test gi predicate", () => {
|
||||
});
|
||||
|
||||
it("should return true", () => {
|
||||
expect(gitPredicate({ repository: { type: "fir" } })).toBe(true);
|
||||
expect(gitPredicate({ repository: { type: "git" } })).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/main/js/index.js",
|
||||
"scripts": {
|
||||
"build": "webpack --mode=development"
|
||||
"build": "webpack --mode=development",
|
||||
"test": "jest --config=../../scm-ui/scripts/jest-plugin.config.js"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.js$": "../../scm-ui/scripts/babelPluginTransformer.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/main/js/index.js",
|
||||
"scripts": {
|
||||
"build": "webpack --mode=development"
|
||||
"build": "webpack --mode=development",
|
||||
"test": "jest --config=../../scm-ui/scripts/jest-plugin.config.js"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.js$": "../../scm-ui/scripts/babelPluginTransformer.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
"version": "2.0.0-SNAPSHOT",
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"build": "webpack --mode=development"
|
||||
"build": "webpack --mode=development",
|
||||
"test": "jest --config=../../scm-ui/scripts/jest-plugin.config.js"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.js$": "../../scm-ui/scripts/babelPluginTransformer.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,17 +75,17 @@
|
||||
<script>build</script>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--execution>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<script>test-ci</script>
|
||||
<script>test</script>
|
||||
<skip>${skipTests}</skip>
|
||||
</configuration>
|
||||
</execution-->
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* Read and use .babelrc from packages
|
||||
*/
|
||||
const { join, resolve } = require("path");
|
||||
const path = require("path");
|
||||
const { createTransformer } = require("babel-jest");
|
||||
|
||||
const packagePath = resolve(__dirname, "../");
|
||||
const packageGlob = join(packagePath, "*");
|
||||
const packagePath = path.resolve(__dirname, "../");
|
||||
const packageGlob = path.join(packagePath, "*");
|
||||
|
||||
module.exports = createTransformer({
|
||||
babelrcRoots: packageGlob
|
||||
|
||||
16
scm-ui/scripts/babelPluginTransformer.js
Normal file
16
scm-ui/scripts/babelPluginTransformer.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Read and use .babelrc from packages
|
||||
*/
|
||||
const path = require("path");
|
||||
const { createTransformer } = require("babel-jest");
|
||||
|
||||
const packagePath = path.resolve(__dirname, "../");
|
||||
const packageGlob = path.join(packagePath, "*");
|
||||
const currentDirectory = path.join(process.cwd());
|
||||
|
||||
module.exports = createTransformer({
|
||||
babelrcRoots: [
|
||||
packageGlob,
|
||||
currentDirectory
|
||||
]
|
||||
});
|
||||
30
scm-ui/scripts/jest-plugin.config.js
Normal file
30
scm-ui/scripts/jest-plugin.config.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const transformer = path.resolve(__dirname, "babelPluginTransformer.js");
|
||||
const rootDir = path.resolve(process.cwd());
|
||||
const packageJsonPath = path.join(rootDir, "package.json");
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(packageJsonPath, { encoding: "UTF-8" })
|
||||
);
|
||||
|
||||
const reportDirectory = path.join(rootDir, "target", "jest-reports");
|
||||
|
||||
module.exports = {
|
||||
rootDir,
|
||||
transform: { "^.+\\.js$": transformer },
|
||||
transformIgnorePatterns: [".*/node_modules/.*"],
|
||||
collectCoverage: true,
|
||||
coverageDirectory: path.join(reportDirectory, "coverage"),
|
||||
coveragePathIgnorePatterns: ["src/main/js/tests/.*"],
|
||||
reporters: [
|
||||
"default",
|
||||
[
|
||||
"jest-junit",
|
||||
{
|
||||
suiteName: packageJson.name + " tests",
|
||||
outputDirectory: reportDirectory,
|
||||
outputName: "TEST-plugin.xml"
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
@@ -12,7 +12,11 @@ module.exports = {
|
||||
"default",
|
||||
[
|
||||
"jest-junit",
|
||||
{ outputDirectory: reportDirectory, outputName: "TEST-all.xml" }
|
||||
{
|
||||
suiteName: "SCM-UI Package tests",
|
||||
outputDirectory: reportDirectory,
|
||||
outputName: "TEST-scm-ui.xml"
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"update-index": "create-index -r src",
|
||||
"eslint-fix": "eslint src --fix"
|
||||
"eslint-fix": "eslint src --fix",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"create-index": "^2.3.0",
|
||||
|
||||
@@ -49,8 +49,7 @@
|
||||
"build-js": "ui-bundler bundle --mode=production target/scm-ui/scm-ui.bundle.js",
|
||||
"build-vendor": "ui-bundler vendor --mode=production target/scm-ui/vendor.bundle.js",
|
||||
"build": "npm-run-all -s webfonts build-css polyfills build-vendor build-js",
|
||||
"test": "ui-bundler test",
|
||||
"test-ci": "ui-bundler test --ci",
|
||||
"test": "jest",
|
||||
"flow": "flow",
|
||||
"pre-commit": "jest && flow && eslint src"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user