diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 91d3295..59cd4b4 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,5 +21,10 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - - name: Run tests - run: yarn test + - name: Test and coverage + run: yarn jest --coverage + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index b3c2eaf..e07a34f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ node_modules/ yarn-error.log yarn.lock prod.env + +# testing +/coverage diff --git a/README.md b/README.md index fd710bc..d148e56 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=daithihearn_cards-110-frontend&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=daithihearn_cards-110-frontend) + # cards-110-frontend The frontend for the [Cards 110 application](https://github.com/daithihearn/cards-110) diff --git a/jest.config.js b/jest.config.js index 0dc796f..d74c261 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,8 @@ module.exports = { moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], testMatch: ["**/*.(spec|test).(ts|tsx|js|jsx)"], maxWorkers: 2, - workerIdleMemoryLimit: "1GB", reporters: ["default", "jest-junit"], + moduleNameMapper: { + "^model/(.*)$": "/src/model/$1", + }, } diff --git a/junit.xml b/junit.xml new file mode 100644 index 0000000..1ed5704 --- /dev/null +++ b/junit.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 58f155b..ea0dbb8 100644 --- a/package.json +++ b/package.json @@ -61,10 +61,12 @@ "@types/react-loadable": "5.5.9", "enzyme": "3.11.0", "enzyme-adapter-react-16": "1.15.7", + "jest-junit": "^16.0.0", "node-sass-chokidar": "2.0.0", "npm-run-all": "4.1.5", "prettier": "3.0.3", - "react-scripts": "5.0.1" + "react-scripts": "5.0.1", + "ts-jest": "^29.1.1" }, "scripts": { "build-css": "node-sass-chokidar --include-path ./node_modules ./src/scss -o ./src/scss", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..9885f8b --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.organization=daithihearn +sonar.projectKey=daithihearn_cards-110-frontend +sonar.sources=src +sonar.tests=src +sonar.test.inclusions=**/*.spec.ts,**/*.spec.tsx +# Exclude from analysis: tests and test helpers +sonar.exclusions=**/*.spec.ts,**/*.spec.tsx,src/test/**/* +# Exclude from coverage: tests, e2e tests, test helpers, content-scripts, service-worker, web-accessible-resources +sonar.coverage.exclusions=**/*.spec.ts,**/*.spec.tsx +sonar.verbose=false +sonar.working.directory=/tmp/sonar +sonar.javascript.lcov.reportPaths=./coverage/lcov.info diff --git a/src/caches/GameSlice.ts b/src/caches/GameSlice.ts index 22f53b8..7c473c6 100644 --- a/src/caches/GameSlice.ts +++ b/src/caches/GameSlice.ts @@ -4,7 +4,6 @@ import { GameState, GameStatus, PlayedCard } from "model/Game" import { Player } from "model/Player" import { RoundStatus } from "model/Round" import { RootState } from "./caches" -import { get } from "http" const initialState: GameState = { iamSpectator: true, diff --git a/src/components/Footer/Footer.spec.tsx b/src/components/Footer/Footer.spec.tsx deleted file mode 100644 index b918eaf..0000000 --- a/src/components/Footer/Footer.spec.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from "react" -import ReactDOM from "react-dom" - -import Footer from "./Footer" - -it("renders without crashing", () => { - const div = document.createElement("div") - ReactDOM.render(