Skip to content

Commit

Permalink
Merge pull request #235 from WodenWang820118/guanxinwang0118/tc-175-a…
Browse files Browse the repository at this point in the history
…op-logging

fix: add test coverage to SonarCloud
  • Loading branch information
WodenWang820118 authored Sep 23, 2024
2 parents 285a8cd + 98ac758 commit 878ae22
Show file tree
Hide file tree
Showing 40 changed files with 1,305 additions and 1,396 deletions.
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pnpm run test:e2e
pnpm run test-back:unit
pnpm run test:cov
node merge-coverage.cjs
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# GTM Container Review and Analytics Validation Tool

// TODO: combine lcov.info to SonarCloud

## Table of Contents

- [Overview](#overview)
Expand Down
2 changes: 1 addition & 1 deletion apps/nest-backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"executor": "@nx/vite:test",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/nest-backend/jest.config.ts",
"jestConfig": "apps/nest-backend/vitest.config.ts",
"passWithNoTests": true
},
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class WaiterConfigurationController {
constructor(private waiterConfigurationService: WaiterConfigurationService) {}

@Get('/debug-sentry')
@Log()
getError() {
throw new Error('My first Sentry error!');
}
Expand Down
9 changes: 9 additions & 0 deletions apps/nest-backend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export default defineConfig({
],
reporters: ['verbose'],
testTimeout: 120000,
coverage: {
enabled: true,
reportsDirectory: '../../coverage/apps/nest-backend',
provider: 'v8',
reporter: ['lcov'],
},
},
esbuild: {
target: 'es2020',
},
plugins: [
nxViteTsPaths(),
Expand Down
1 change: 1 addition & 0 deletions apps/ng-frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/apps/ng-frontend',
testEnvironment: 'jsdom',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
Expand Down
3 changes: 3 additions & 0 deletions apps/ng-frontend/jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import nxPreset from '@nx/jest/preset.js';

export default { ...nxPreset };
9 changes: 8 additions & 1 deletion apps/ng-frontend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/ng-frontend/jest.config.ts"
"jestConfig": "apps/ng-frontend/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"serve-static": {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 8 additions & 1 deletion apps/ng-tag-build/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/ng-tag-build/jest.config.ts"
"jestConfig": "apps/ng-tag-build/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions apps/ng-tag-build/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
import 'jest-preset-angular/setup-jest';
4 changes: 2 additions & 2 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;
import nxPreset from '@nx/jest/preset.js';

module.exports = { ...nxPreset };
export default { ...nxPreset };
3 changes: 2 additions & 1 deletion libs/data-access/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ui/jest.config.ts"
"jestConfig": "libs/ui/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
Expand Down
2 changes: 1 addition & 1 deletion libs/data-access/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "./../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
Expand Down
1 change: 1 addition & 0 deletions libs/ui/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/ui',
testEnvironment: 'jsdom',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
Expand Down
3 changes: 2 additions & 1 deletion libs/ui/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ui/jest.config.ts"
"jestConfig": "libs/ui/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions libs/ui/src/lib/components/article/article.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ArticleComponent } from './article.component';

describe('ArticleComponent', () => {
Expand All @@ -8,7 +7,7 @@ describe('ArticleComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ArticleComponent]
imports: [ArticleComponent],
});
fixture = TestBed.createComponent(ArticleComponent);
component = fixture.componentInstance;
Expand Down

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions libs/ui/src/lib/components/editor/editor.component.spec.ts

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions libs/ui/src/lib/components/footer/footer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FooterComponent } from './footer.component';

describe('FooterComponent', () => {
Expand All @@ -8,7 +7,7 @@ describe('FooterComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FooterComponent]
imports: [FooterComponent],
});
fixture = TestBed.createComponent(FooterComponent);
component = fixture.componentInstance;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('ProgressSpinnerComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ProgressSpinnerComponent]
imports: [ProgressSpinnerComponent],
});
fixture = TestBed.createComponent(ProgressSpinnerComponent);
component = fixture.componentInstance;
Expand Down
Loading

0 comments on commit 878ae22

Please sign in to comment.