Skip to content

Commit

Permalink
Report coverage from cypress tests (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
caponetto authored Dec 10, 2024
1 parent 37b0487 commit ffbf956
Show file tree
Hide file tree
Showing 28 changed files with 406 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,19 @@ jobs:
run: |
make build-dependencies
make yarn-install
make test-instrument
make build-ui-prod
- name: Install
run: |
make install-server
make install-examples
- name: Cypress
run: make test-integration
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/cobertura-coverage.xml
- name: Collect logs
uses: actions/upload-artifact@v4
if: failure()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nosetests.xml
coverage.xml
*,cover
**/coverage/
.nyc_output/

# Translations
*.mo
Expand Down
12 changes: 12 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "nyc-config-tsx",
"all": true,
"include": ["**/src/**/*.{ts,tsx}"],
"exclude": ["**/*.spec.ts", "tests/**/*"],
"reporter": ["text-summary", "cobertura"],
"check-coverage": true,
"lines": 72,
"functions": 68,
"branches": 53,
"statements": 72
}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ test-server: test-dependencies pytest # Run python unit tests
test-ui-unit: # Run frontend jest unit tests
yarn test:unit

test-instrument: # Prepare code coverage instrumentation
yarn lerna run cy:instrument --stream

test-integration: # Run frontend cypress integration tests
yarn test:integration

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"graph": "ts-node etc/scripts/generate-make-graph.ts",
"cy:open": "npx cypress open",
"cy:run": "npx cypress run",
"cy:run": "npx nyc npx cypress run",
"eslint": "eslint . --fix --ignore-path .gitignore --ext .ts,.tsx,.js",
"eslint:check": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js",
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
Expand Down Expand Up @@ -45,6 +45,7 @@
"yjs": "^13.5.40"
},
"devDependencies": {
"@cypress/code-coverage": "^3.13.8",
"@cypress/webpack-preprocessor": "^5.5.0",
"@glen/jest-raw-loader": "^2.0.0",
"@jupyterlab/testutils": "^4.2.5",
Expand Down Expand Up @@ -73,6 +74,8 @@
"lerna": "^8.0.1",
"lint-staged": "^15.2.0",
"npm-run-all": "^4.1.5",
"nyc": "^17.1.0",
"nyc-config-tsx": "^0.1.0",
"prettier": "^3.1.1",
"rimraf": "~5.0.5",
"start-server-and-test": "^2.0.3",
Expand Down
1 change: 1 addition & 0 deletions packages/code-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_code_snippet_extension/labextension ../../../../labextensions/elyra_code_snippet_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/metadata-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_metadata_common/labextension ../../../../labextensions/elyra_metadata_common/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_metadata_extension/labextension ../../../../labextensions/elyra_metadata_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/pipeline-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_pipeline_editor_extension/labextension ../../../../labextensions/elyra_pipeline_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
6 changes: 3 additions & 3 deletions packages/pipeline-editor/src/PipelineEditorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const getAllPaletteNodes = (
return [];
}

const nodes = [];
const nodes: IRuntimeComponentNodeType[] = [];
for (const c of palette.categories) {
if (c.node_types) {
nodes.push(...c.node_types);
Expand Down Expand Up @@ -282,7 +282,7 @@ const PipelineWrapper: React.FC<
const runtimeDisplayName = getDisplayName(runtimesSchema, type) ?? 'Generic';

const filePersistedRuntimeImages = useMemo(() => {
const images = [];
const images: string[] = [];
const pipelineDefaultRuntimeImage =
pipeline?.pipelines?.[0]?.app_data?.properties?.pipeline_defaults
?.runtime_image;
Expand Down Expand Up @@ -665,7 +665,7 @@ const PipelineWrapper: React.FC<
(componentId: string, componentSource: string) => {
// Show error dialog if the component does not exist
if (!componentId) {
const dialogBody = [];
const dialogBody: string[] = [];
try {
const componentSourceJson = JSON.parse(componentSource);
dialogBody.push(`catalog_type: ${componentSourceJson.catalog_type}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/pipeline-editor/src/RuntimesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class RuntimesDisplay extends MetadataDisplay<IRuntimesDisplayProps> {
metadata.metadata.cos_endpoint as string
);

let githubRepoElement = null;
let metadata_props = null;
let githubRepoElement: JSX.Element | null = null;
let metadata_props: GenericObjectType | null = null;

for (const schema of this.props.schemas ?? []) {
if (schema.name === metadata.schema_name) {
Expand Down
1 change: 1 addition & 0 deletions packages/pipeline-editor/src/test/pipeline-hooks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
IRuntimeComponent,
GENERIC_CATEGORY_ID,
Expand Down
1 change: 1 addition & 0 deletions packages/python-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_python_editor_extension/labextension ../../../../labextensions/elyra_python_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/script-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_script_debugger_extension/labextension ../../../../labextensions/elyra_script_debugger_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
2 changes: 1 addition & 1 deletion packages/script-debugger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const scriptEditorDebuggerExtension: JupyterFrontEndPlugin<void> = {
type: 'file',
name: path
};
let sessionConnection = null;
let sessionConnection: Session.ISessionConnection | null = null;
try {
if (kernelSelection) {
sessionConnection = await sessionManager.startNew(options);
Expand Down
1 change: 1 addition & 0 deletions packages/script-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_script_editor/labextension ../../../../labextensions/elyra_script_editor/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_services/labextension ../../../../labextensions/elyra_services/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensionselyra_theme_extension/labextension ../../../../labextensionselyra_theme_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_ui_components/labextension ../../../../labextensions/elyra_ui_components/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/src/FormComponents/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const Tags: React.FC<ITagProps> = ({
};

export const TagsField: React.FC<FieldProps> = (props: FieldProps) => {
const errors = [];
const errors: JSX.Element[] = [];
const errorSchema = props.errorSchema ?? {};
if (Object.keys(errorSchema).length > 0) {
for (const i in props.errorSchema) {
Expand Down
4 changes: 4 additions & 0 deletions tests/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
* limitations under the License.
*/

import codeCoverage from '@cypress/code-coverage/task';

import { register } from './../utils/snapshots/plugin';

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- workaround for snapshot plugin
export default (on: any, config: any): void => {
register(on, config);
codeCoverage(on, config);
return config;
};
2 changes: 2 additions & 0 deletions tests/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import '@cypress/code-coverage/support';

import '@testing-library/cypress/add-commands';

import 'cypress-real-events/support';
Expand Down
1 change: 1 addition & 0 deletions tests/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Chainable {
Expand Down
7 changes: 1 addition & 6 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"extends": "../tsconfig.base.json",
"compilerOptions": {
"isolatedModules": false,
"types": [
"@types/jest",
"cypress",
"@testing-library/cypress",
"cypress-real-events"
],
"types": ["cypress", "@testing-library/cypress", "cypress-real-events"],
"sourceMap": false
},
"include": ["**/*.ts"]
Expand Down
2 changes: 1 addition & 1 deletion testutils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
'^.+\\.(j|t)sx?$': [
'ts-jest',
{
tsConfig: '../../tests/tsconfig.json'
tsConfig: '../../testutils/tsconfig.jest.json'
}
],
'\\.svg$': '@glen/jest-raw-loader'
Expand Down
7 changes: 7 additions & 0 deletions testutils/tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"types": ["@types/jest"]
},
"include": ["**/*.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Additional Checks */
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noFallthroughCasesInSwitch": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,

Expand Down
Loading

0 comments on commit ffbf956

Please sign in to comment.