From 272295ad13d5ea3e732d8b624c09ab03991cd9cf Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Fri, 12 May 2023 02:19:54 -0700 Subject: [PATCH 1/9] Testing FIx --- .github/workflows/coverage_report.yml | 21 +---- .github/workflows/tests.yml | 21 +---- .gitignore | 2 + backend/jest.config.js | 8 +- backend/package.json | 4 +- backend/src/__tests__/smoke.test.ts | 6 +- .../src/__tests__/{Feed.test.tsx => Feed.txt} | 0 jest.config.js | 41 +++++++++ package.json | 84 +++++++++++++++++++ 9 files changed, 141 insertions(+), 46 deletions(-) rename frontend/src/__tests__/{Feed.test.tsx => Feed.txt} (100%) create mode 100644 jest.config.js create mode 100644 package.json diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 19453590..a704b20f 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -2,10 +2,10 @@ name: Coverage Report on: pull_request: - branches: [main , frontend_testing] + branches: [main , consolidated2] jobs: - backend: + Coverage_Report: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -14,24 +14,7 @@ jobs: node-version: 16 - name: Install dependencies run: | - cd backend - npm install --save-dev typescript-coverage-report - - name: Generate coverage report - run: | - cd backend - npm run ts-coverage - frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install dependencies - run: | - cd frontend npm install - name: Generate coverage report run: | - cd frontend npm run coverage diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 88f52cb7..f0940b56 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,10 +2,10 @@ name: Testing on: pull_request: - branches: [main] + branches: [main,consolidated2] jobs: - backend: + Testingz: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -14,24 +14,7 @@ jobs: node-version: 16 - name: Install dependencies run: | - cd backend npm ci - name: Test run: | - cd backend - npm test - frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install dependencies - run: | - cd frontend - npm ci - - name: Test - run: | - cd frontend npm test diff --git a/.gitignore b/.gitignore index f432face..4281cae9 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,5 @@ models/*.js # MacOS .DS_Store + +package-lock.json \ No newline at end of file diff --git a/backend/jest.config.js b/backend/jest.config.js index beaac3f6..b29c6146 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -5,5 +5,11 @@ module.exports = { //"/node_modules/", //"\\.pc/", // "/frontend/", - ] + ], testMatch: [ + '/src/**/__tests__/**/*.{ts,tsx}', + '/src/**/*.{spec,test}.{ts,tsx}', + ], + collectCoverage: true, + collectCoverageFrom: ["src/**/*.{ts,tsx}", "!**/node_modules/**"], + verbose: true }; diff --git a/backend/package.json b/backend/package.json index 8335159b..c8de401c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -7,7 +7,7 @@ "build": "tsc -p .", "test": "jest", "lint": "eslint --fix --ext .ts,.js .", - "ts-coverage": "typescript-coverage-report" + "coverage": "jest --coverage" }, "dependencies": { "@ericblade/quagga2": "^1.8.2", @@ -63,4 +63,4 @@ "ts-node-dev": "^2.0.0", "typescript": "^4.9.5" } -} +} \ No newline at end of file diff --git a/backend/src/__tests__/smoke.test.ts b/backend/src/__tests__/smoke.test.ts index 2dbb9b63..32a544ca 100644 --- a/backend/src/__tests__/smoke.test.ts +++ b/backend/src/__tests__/smoke.test.ts @@ -1,11 +1,7 @@ describe('smoke test', () => { test('returns an integer 2', () => { - expect(1+1).toBe(2); + expect(1 + 1).toBe(2); }); - test('can import entry point without errors', () => { - expect(() => require('../routes/index.js')).not.toThrow(); - }); - }); diff --git a/frontend/src/__tests__/Feed.test.tsx b/frontend/src/__tests__/Feed.txt similarity index 100% rename from frontend/src/__tests__/Feed.test.tsx rename to frontend/src/__tests__/Feed.txt diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..f2f43dba --- /dev/null +++ b/jest.config.js @@ -0,0 +1,41 @@ +module.exports = { + projects: [ + { + displayName: 'frontend TEST', + testEnvironment: 'jsdom', + testMatch: ['/frontend/__tests__/**/*.{js,jsx,ts,tsx}'], + rootDir: '.', + testPathIgnorePatterns: ['/backend'], + moduleDirectories: ['frontend/node_modules'], + testMatch: [ + '/frontend/src/**/__tests__/**/*.{js,jsx,ts,tsx}', + '/frontend/src/**/*.{spec,test}.{js,jsx,ts,tsx}', + ], + transform: { + '^.+\\.(ts|js|tsx|jsx)$': '@swc/jest', + }, setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'] + }, + { + displayName: 'backend TEST', + testEnvironment: 'node', + testMatch: ['/backend/__tests__/**/*.{js,jsx,ts,tsx}'], + moduleDirectories: ['backend/node_modules'], + rootDir: '.', + //setupFilesAfterEnv: ['@types/express'], + testMatch: [ + '/backend/src/**/__tests__/**/*.{ts,tsx}', + '/backend/src/**/*.{spec,test}.{ts,tsx}', + ] + }, + ], + collectCoverage: true, + coverageDirectory: './docs/coverage', + collectCoverageFrom: [ + 'frontend/src/pages/**/*.{ts,tsx}', + 'frontend/src/Components/**/*.{ts,tsx}', + 'backend/src/models/*.ts', + 'backend/src/routes/*.ts', + '!**/node_modules/**', + ], + coverageReporters: ['html', 'text', 'lcov'], +}; diff --git a/package.json b/package.json new file mode 100644 index 00000000..11233bbd --- /dev/null +++ b/package.json @@ -0,0 +1,84 @@ +{ + "name": "combinedcoveragereport", + "version": "0.0.0", + "private": true, + "dependencies": { + "@emotion/react": "^11.10.6", + "@emotion/styled": "^11.10.6", + "@ericblade/quagga2": "^1.8.2", + "@fontsource/roboto": "^4.5.8", + "@mui/icons-material": "^5.11.11", + "@mui/material": "^5.11.12", + "@reduxjs/toolkit": "^1.9.3", + "@swc/jest": "^0.2.26", + "@testing-library/react": "^14.0.0", + "@types/jest": "^29.5.0", + "@types/express": "^4.17.17", + "@types/node": "^16.18.13", + "@types/passport": "^1.0.12", + "@types/react": "^18.0.28", + "@types/react-dom": "^18.0.11", + "@types/react-router-dom": "^5.3.3", + "@typescript-eslint/eslint-plugin": "^5.58.0", + "@typescript-eslint/parser": "^5.58.0", + "axios": "^1.4.0", + "bcrypt": "^5.0.0", + "bcryptjs": "^2.4.3", + "body-parser": "^1.19.0", + "connect-flash": "^0.1.1", + "cookie-parser": "^1.4.5", + "cookie-session": "^1.4.0", + "cors": "^2.8.5", + "debug": "~2.6.9", + "dotenv": "^16.0.3", + "ejs": "^3.1.9", + "expres": "^0.0.5", + "express": "^4.18.2", + "express-favicon": "^2.0.1", + "express-session": "^1.17.1", + "fontawesome": "^5.6.3", + "http-errors": "~1.6.3", + "jade": "~1.11.0", + "jest": "^29.5.0", + "jest-environment-jsdom": "^29.5.0", + "jshint-reporter-badge": "^0.1.0", + "jslint": "^0.12.1", + "jsonwebtoken": "^9.0.0", + "miragejs": "^0.1.47", + "mongoose": "^5.9.11", + "morgan": "~1.9.1", + "nodemon": "^2.0.22", + "passport": "^0.6.0", + "passport-local": "^1.0.0", + "pg": "^8.9.0", + "pg-hstore": "^2.3.4", + "quagga": "^0.12.1", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-redux": "^8.0.5", + "react-router-dom": "^6.10.0", + "recharts": "^2.5.0", + "run": "^1.4.0", + "typescript": "^4.9.5", + "web-vitals": "^2.1.4" + }, + "scripts": { + "build": "react-scripts build", + "test": "jest --no-coverage", + "coverage": "jest --coverage" + }, + "devDependencies": { + "@swc/jest": "^0.2.26", + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^14.0.0", + "@types/jest": "^29.5.0", + "@types/react-dom": "^18.0.11", + "@types/express": "^4.17.17", + "@types/react-router-dom": "^5.3.3", + "jest": "^29.5.0", + "jest-environment-jsdom": "^29.5.0", + "miragejs": "^0.1.47", + "react-router-dom": "^6.10.0", + "ts-jest": "^29.1.0" + } +} \ No newline at end of file From 3852dd19b3e433a48c20c747f8ace9c2f8eedb3c Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Fri, 12 May 2023 02:25:26 -0700 Subject: [PATCH 2/9] retry --- .github/workflows/tests.yml | 2 +- .gitignore | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f0940b56..f91b5621 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: node-version: 16 - name: Install dependencies run: | - npm ci + npm install - name: Test run: | npm test diff --git a/.gitignore b/.gitignore index 4281cae9..f432face 100644 --- a/.gitignore +++ b/.gitignore @@ -138,5 +138,3 @@ models/*.js # MacOS .DS_Store - -package-lock.json \ No newline at end of file From 58df93ac8dc208a26f2ce1e562f6dbbdfaf102fe Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Fri, 12 May 2023 02:29:55 -0700 Subject: [PATCH 3/9] fix2 --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 11233bbd..5d10a292 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "@reduxjs/toolkit": "^1.9.3", "@swc/jest": "^0.2.26", "@testing-library/react": "^14.0.0", - "@types/jest": "^29.5.0", "@types/express": "^4.17.17", + "@types/jest": "^29.5.0", "@types/node": "^16.18.13", "@types/passport": "^1.0.12", "@types/react": "^18.0.28", @@ -71,14 +71,15 @@ "@swc/jest": "^0.2.26", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", + "@types/express": "^4.17.17", "@types/jest": "^29.5.0", "@types/react-dom": "^18.0.11", - "@types/express": "^4.17.17", "@types/react-router-dom": "^5.3.3", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "miragejs": "^0.1.47", "react-router-dom": "^6.10.0", + "source-map": "^0.7.4", "ts-jest": "^29.1.0" } -} \ No newline at end of file +} From 12729e73f23c2b73106948d9d205cd5311799c39 Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Sat, 13 May 2023 01:50:54 -0700 Subject: [PATCH 4/9] Possible Fix to Consolidated coverage&test action --- .github/workflows/actions | 39 +++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 2 +- .gitignore | 2 ++ jest.config.js | 10 +++++----- package.json | 5 +++-- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/actions diff --git a/.github/workflows/actions b/.github/workflows/actions new file mode 100644 index 00000000..31ec128f --- /dev/null +++ b/.github/workflows/actions @@ -0,0 +1,39 @@ +name: Build Node + +on: + push: + branches: [main, frontend] + pull_request: + branches: [main, frontend] + +jobs: + backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install dependencies + run: | + cd backend + npm ci + - name: Build + run: | + cd backend + npm run build + frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install dependencies + run: | + cd frontend + npm ci + - name: Build + run: | + cd frontend + npm run build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f91b5621..e78087a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,7 @@ on: branches: [main,consolidated2] jobs: - Testingz: + Testing: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index f432face..4281cae9 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,5 @@ models/*.js # MacOS .DS_Store + +package-lock.json \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index f2f43dba..affdedf1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,12 +1,12 @@ module.exports = { projects: [ { - displayName: 'frontend TEST', + displayName: 'FE TEST', testEnvironment: 'jsdom', testMatch: ['/frontend/__tests__/**/*.{js,jsx,ts,tsx}'], rootDir: '.', testPathIgnorePatterns: ['/backend'], - moduleDirectories: ['frontend/node_modules'], + moduleDirectories: ['node_modules'], testMatch: [ '/frontend/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '/frontend/src/**/*.{spec,test}.{js,jsx,ts,tsx}', @@ -16,10 +16,10 @@ module.exports = { }, setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'] }, { - displayName: 'backend TEST', + displayName: 'BE TEST', testEnvironment: 'node', testMatch: ['/backend/__tests__/**/*.{js,jsx,ts,tsx}'], - moduleDirectories: ['backend/node_modules'], + moduleDirectories: ['node_modules'], rootDir: '.', //setupFilesAfterEnv: ['@types/express'], testMatch: [ @@ -37,5 +37,5 @@ module.exports = { 'backend/src/routes/*.ts', '!**/node_modules/**', ], - coverageReporters: ['html', 'text', 'lcov'], + coverageReporters: ['html'], }; diff --git a/package.json b/package.json index 5d10a292..3af8574a 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "express-favicon": "^2.0.1", "express-session": "^1.17.1", "fontawesome": "^5.6.3", + "formik": "^2.2.9", "http-errors": "~1.6.3", "jade": "~1.11.0", "jest": "^29.5.0", @@ -44,6 +45,7 @@ "jshint-reporter-badge": "^0.1.0", "jslint": "^0.12.1", "jsonwebtoken": "^9.0.0", + "jwt-decode": "^3.1.2", "miragejs": "^0.1.47", "mongoose": "^5.9.11", "morgan": "~1.9.1", @@ -63,7 +65,6 @@ "web-vitals": "^2.1.4" }, "scripts": { - "build": "react-scripts build", "test": "jest --no-coverage", "coverage": "jest --coverage" }, @@ -82,4 +83,4 @@ "source-map": "^0.7.4", "ts-jest": "^29.1.0" } -} +} \ No newline at end of file From 786665b59bcf881d6620fec8de2d6b8370a79c31 Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Sat, 13 May 2023 01:51:45 -0700 Subject: [PATCH 5/9] Commit --- .github/workflows/actions | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/actions diff --git a/.github/workflows/actions b/.github/workflows/actions deleted file mode 100644 index 31ec128f..00000000 --- a/.github/workflows/actions +++ /dev/null @@ -1,39 +0,0 @@ -name: Build Node - -on: - push: - branches: [main, frontend] - pull_request: - branches: [main, frontend] - -jobs: - backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install dependencies - run: | - cd backend - npm ci - - name: Build - run: | - cd backend - npm run build - frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install dependencies - run: | - cd frontend - npm ci - - name: Build - run: | - cd frontend - npm run build From ccc7fa9d09a6aa5426ae26f83af6f0b1d7ade75e Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Sat, 13 May 2023 02:24:09 -0700 Subject: [PATCH 6/9] removing experimental changes --- .github/workflows/linter.yml | 2 +- .github/workflows/tests.yml | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 41e2c0bd..0a6f7a86 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -2,7 +2,7 @@ name: ES Lint on: pull_request: - branches: [main, frontend] + branches: [main] jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e78087a0..ebf51e15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,10 +2,10 @@ name: Testing on: pull_request: - branches: [main,consolidated2] + branches: [main] jobs: - Testing: + backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -14,7 +14,24 @@ jobs: node-version: 16 - name: Install dependencies run: | - npm install + cd backend + npm ci - name: Test run: | + cd backend npm test + frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install dependencies + run: | + cd frontend + npm ci + - name: Test + run: | + cd frontend + npm test \ No newline at end of file From 2b00a5775bc18a856520b5f433ca0cef0c9a6a64 Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Sat, 13 May 2023 02:26:44 -0700 Subject: [PATCH 7/9] coverage for push to main --- .github/workflows/coverage_report.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index a704b20f..1819fffc 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -2,8 +2,10 @@ name: Coverage Report on: pull_request: - branches: [main , consolidated2] - + branches: [main] + push: + branches: + - main jobs: Coverage_Report: runs-on: ubuntu-latest From 021513932274d9cd6a8f09febdcea77655543e33 Mon Sep 17 00:00:00 2001 From: chetan2298 <45332082+chetan2298@users.noreply.github.com> Date: Sat, 13 May 2023 02:35:20 -0700 Subject: [PATCH 8/9] Coverage html, text --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index affdedf1..1536396a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -37,5 +37,5 @@ module.exports = { 'backend/src/routes/*.ts', '!**/node_modules/**', ], - coverageReporters: ['html'], + coverageReporters: ['html', 'text', 'lcov'], }; From d8fa6372c03e8f4a0285c5645dc0d89b29e9d0d8 Mon Sep 17 00:00:00 2001 From: Chaitanya <45332082+chetan2298@users.noreply.github.com> Date: Mon, 15 May 2023 21:11:17 -0700 Subject: [PATCH 9/9] Restored experimental change --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 0a6f7a86..ad007857 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -2,7 +2,7 @@ name: ES Lint on: pull_request: - branches: [main] + branches: [main,frontend] jobs: lint: runs-on: ubuntu-latest