Skip to content

Commit

Permalink
chore(meta): Add a test for testing coverage system (#4794)
Browse files Browse the repository at this point in the history
* test(designer): Add tests for display of scope ids

* test(designer): Add tests for display of scope ids

* Add a test

* test(designer): fix tests

* test(designer): fix tests
  • Loading branch information
hartra344 committed May 7, 2024
1 parent 1951762 commit 19585a4
Show file tree
Hide file tree
Showing 7 changed files with 341 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/coverage-report.yml
Expand Up @@ -37,7 +37,7 @@ jobs:
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- run: pnpm turbo run test:lib --cache-dir=.turbo -- --changed origin/main
- run: pnpm turbo run test:lib --cache-dir=.turbo
- name: Create code coverage report
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
Expand All @@ -56,6 +56,7 @@ jobs:

- name: Write to Job Summary
run: cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- run: node ./filterCoverageMarkdown.js
- name: Add Coverage PR Comment
#Make sure the report was generated and that the event is actually a pull request, run if failed or success
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
292 changes: 292 additions & 0 deletions code-coverage-results.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions coverage.xml

This file was deleted.

14 changes: 14 additions & 0 deletions filterCoverageMarkdown.js
@@ -0,0 +1,14 @@
import fs from 'fs';

fs.readFile('code-coverage-results.md', 'utf8', (err, data) => {
if (err) throw err;

const lines = data.split('\n'); // Split data into lines
const filteredLines = lines.filter((line) => !line.includes('⚪ 0%')); // Filter lines

fs.writeFile('code-coverage-results.md', filteredLines.join('\n'), (err) => {
if (err) throw err;
// eslint-disable-next-line no-undef
console.log('Filtered file has been saved!');
});
});
11 changes: 11 additions & 0 deletions filtered_code-coverage-results.md
@@ -0,0 +1,11 @@
# Code Coverage Report

![Code Coverage](https://img.shields.io/badge/Code%20Coverage-25.14%25-red?style=for-the-badge)

| Package | Base Coverage | New Coverage | Difference |
| ------- | ------------- | ------------ | ---------- |
| utils.src.lib.helpers | 🟠 56.45% | 🟠 56.59% | 🟢 0.14% |
| **Overall Coverage** | **🟢 25.13%** | **🟢 25.14%** | **🟢 0.01%** |

_Minimum allowed coverage is_ `0%`_, this run produced_ `25.14%`
<!-- Sticky Pull Request Comment -->
@@ -1,4 +1,4 @@
import { idDisplayCase, labelCase } from '../stringFunctions';
import { escapeString, idDisplayCase, labelCase } from '../stringFunctions';
import { describe, it, expect } from 'vitest';
describe('label_case', () => {
it('should replace _ with spaces', () => {
Expand Down Expand Up @@ -26,4 +26,25 @@ describe('idDisplayCase', () => {
it('should handle a string with only an ID tag', () => {
expect(idDisplayCase('-#Scope')).toEqual('');
});
});

describe('escapeString', () => {
it('should correctly escape backslashes', () => {
expect(escapeString('\\')).toEqual('\\\\');
expect(escapeString('Test\\Test')).toEqual('Test\\\\Test');
});

it('should correctly escape newline characters', () => {
expect(escapeString('\n')).toEqual('\\n');
expect(escapeString('Test\nTest')).toEqual('Test\\nTest');
});

it('should correctly escape backslashes and newline characters together', () => {
expect(escapeString('\\\n')).toEqual('\\\\\\n');
expect(escapeString('Test\\\nTest')).toEqual('Test\\\\\\nTest');
});

it('should handle an empty string', () => {
expect(escapeString('')).toEqual('');
});
});
10 changes: 0 additions & 10 deletions merge-lcov.sh

This file was deleted.

0 comments on commit 19585a4

Please sign in to comment.