Skip to content

Commit

Permalink
Correção da configuração do jest para o sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
isadoragalvaoss committed May 26, 2023
1 parent 8b62d63 commit 093fe60
Show file tree
Hide file tree
Showing 8 changed files with 8,054 additions and 8,078 deletions.
10 changes: 10 additions & 0 deletions .jest/setup-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "@testing-library/jest-dom";

const config = {
reporters: [
"default",
["jest-junit", { outputDirectory: "reports", outputName: "report.xml" }],
],
};

module.exports = config;
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test-file-stub";
23 changes: 23 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
presets: [
"@babel/preset-env",
[
"@babel/preset-react",
{
runtime: "automatic",
},
],
"@babel/preset-typescript",
],
plugins: [
function () {
return {
visitor: {
MetaProperty(path) {
path.replaceWithSourceString("process");
},
},
};
},
],
};
8 changes: 8 additions & 0 deletions jest-report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<testExecutions version="1">
<file path="src\tests\Login.test.tsx">
<testCase name="should render Login" duration="318" />
</file>
<file path="src\tests\Cadastro.test.tsx">
<testCase name="should render Login text" duration="342" />
</file>
</testExecutions>
34 changes: 34 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
coverageReporters: ["json-summary", "text", "lcov"],
collectCoverageFrom: [
"src/**/**/*.{ts,tsx}",
"src/**/**/**/*.{ts,tsx}",
"!src/**/**/**/*.dto.{ts,tsx}",
"!src/styles/globalStyle.ts",
"!src/vite-env.d.ts",
"!src/index.tsx",
"!src/App.tsx",
],
collectCoverage: true,
testEnvironment: "jest-environment-jsdom",
setupFilesAfterEnv: ["<rootDir>/.jest/setup-tests.js"],
transform: {
".*\\.[jt]sx?$": "babel-jest",
},
reporters: [
"default",
[
"jest-sonar",
{
outputDirectory: "./",
outputName: "jest-report.xml",
reportedFilePath: "relative",
relativeRootDir: "<rootDir>/../",
},
],
],
moduleNameMapper: {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$":
"<rootDir>/__mocks__/fileMock.js",
},
};
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/core": "^7.21.8",
"@babel/plugin-proposal-decorators": "^7.21.0",
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.5",
"@fortawesome/fontawesome-free": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
Expand All @@ -14,7 +19,10 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"antd": "^5.5.0",
"babel-loader": "^9.1.2",
"babel-plugin-macros": "^3.1.0",
"jest-sonar": "^0.2.16",
"jest-sonar-reporter": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
Expand Down
10 changes: 2 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src", "tests"]
}
Loading

0 comments on commit 093fe60

Please sign in to comment.