Skip to content

Commit

Permalink
chore: add code coverage and actions workflow (codecov) (#5008)
Browse files Browse the repository at this point in the history
* chore: add codecov action

* chore: add codecov action

* fix: remove unused screen debug

---------

Co-authored-by: Christopher  Tannum <christopher.tannum@cognitedata.com>
  • Loading branch information
christjt and Christopher Tannum authored Feb 21, 2025
1 parent daa0619 commit 156dfeb
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/react-components-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ jobs:
- name: Unit tests
working-directory: react-components
continue-on-error: false
run: yarn run test
run: yarn run test:coverage
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Install playwright browsers
working-directory: react-components
continue-on-error: false
Expand Down
2 changes: 2 additions & 0 deletions react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"tsc": "tsc",
"lint": "eslint . --cache",
"test": "vitest run --dom",
"test:coverage": "vitest run --dom --coverage",
"test:playwright": "playwright test",
"test:watch": "vitest watch --dom",
"pull-keys": "cdf-i18n-utils-cli pull-keys-from-remote --namespace reveal-react-components --path ./src/common/i18n && yarn sort-keys",
Expand Down Expand Up @@ -69,6 +70,7 @@
"@types/three": "0.165.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.5.3",
"core-js": "^3.6.5",
"eslint": "^8.57.0",
"eslint-config-love": "47.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Copyright 2025 Cognite AS
*/
import { render, screen } from '@testing-library/react';
import { render } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import type { PropsWithChildren, ReactElement } from 'react';
import { Reveal3DResources } from './Reveal3DResources';
Expand Down Expand Up @@ -50,7 +50,6 @@ describe(Reveal3DResources.name, () => {
</Reveal3DResourcesContext.Provider>
);
render(<Reveal3DResources {...defaultProps} />, { wrapper });
screen.debug();
});

it('should mount CadModelContainer if styling is resolved', () => {
Expand Down Expand Up @@ -81,7 +80,6 @@ describe(Reveal3DResources.name, () => {
wrapper
});
expect(CadModelContainer).toHaveBeenCalledTimes(2);
screen.debug();
});

it('should mount PointCloudContainer if styling is resolved', () => {
Expand Down
7 changes: 6 additions & 1 deletion react-components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dts from 'vite-plugin-dts';
import { externalizeDeps } from 'vite-plugin-externalize-deps';
import { exec } from 'node:child_process';

export default defineConfig(({ command, mode }) => {
export default defineConfig(({ command }) => {
return {
plugins: [
react(),
Expand All @@ -31,6 +31,11 @@ export default defineConfig(({ command, mode }) => {
'tests/unit-tests/**/*.{test,spec}.?(c|m)[jt]s?(x)',
'src/**/*.{test,spec}.?(c|m)[jt]s?(x)'
],
reporters: ['default'],
coverage: {
reportsDirectory: '../coverage/reveal-react-components',
exclude: ['src/**/*.spec.ts', 'src/**/*.spec.tsx', 'src/**/*.test.ts', 'src/**/*.test.tsx']
},
// Need to add E5 modules as inlined dependencies to be able to import them in tests.
server: {
deps: {
Expand Down
185 changes: 183 additions & 2 deletions react-components/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 156dfeb

Please sign in to comment.