From fd64d321ec48256a5e3ac041ef8044467c59e41f Mon Sep 17 00:00:00 2001 From: Leangseu Kim Date: Fri, 23 Feb 2024 13:39:25 -0500 Subject: [PATCH] chore: update tests so we have less error message --- jest.config.js | 22 +++++++++++++-- package-lock.json | 15 ++++++++++ package.json | 3 +- .../courseware-search/CoursewareSearch.jsx | 2 +- .../CompleteDonutSegment.jsx | 2 +- .../IncompleteDonutSegment.jsx | 2 +- .../course-completion/LockedDonutSegment.jsx | 2 +- .../detailed-grades/ProblemScoreDrawer.jsx | 5 ++-- src/courseware/CoursewareContainer.test.jsx | 1 + src/courseware/course/CourseBreadcrumbs.jsx | 5 +++- .../__snapshots__/index.test.jsx.snap | 28 ++++++++++++++++++- .../Unit/translation-selection/index.test.jsx | 2 +- .../SequenceNavigationDropdown.jsx | 2 +- src/courseware/course/sidebar/Sidebar.jsx | 2 +- .../notifications/NotificationIcon.jsx | 6 +++- src/index.jsx | 2 ++ .../masquerade-widget/MasqueradeWidget.jsx | 2 +- src/product-tours/ProductTours.test.jsx | 1 + src/setupTest.js | 17 +++++++++-- 19 files changed, 103 insertions(+), 18 deletions(-) diff --git a/jest.config.js b/jest.config.js index 8c69451cbf..814debb5fb 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,6 @@ const { createConfig } = require('@edx/frontend-build'); -module.exports = createConfig('jest', { +const config = createConfig('jest', { setupFilesAfterEnv: [ '/src/setupTest.js', ], @@ -17,5 +17,23 @@ module.exports = createConfig('jest', { }, testTimeout: 30000, testEnvironment: 'jsdom', - globalSetup: "./global-setup.js" + globalSetup: "./global-setup.js", }); + +config.reporters = [...(config.reporters || []), ["jest-console-group-reporter", { + // change this setting if need to see less details for each test + // reportType: "summary" | "details", + // enable: true | false, + afterEachTest: { + enable: true, + filePaths: false, + reportType: "details", + }, + afterAllTests: { + reportType: "summary", + enable: true, + filePaths: true, + }, +}]]; + +module.exports = config; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5aa8b93847..830f9323ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -67,6 +67,7 @@ "es-check": "6.2.1", "husky": "7.0.4", "jest": "29.5.0", + "jest-console-group-reporter": "^1.0.1", "rosie": "2.1.1" } }, @@ -14465,6 +14466,20 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/jest-console-group-reporter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/jest-console-group-reporter/-/jest-console-group-reporter-1.0.1.tgz", + "integrity": "sha512-r5I28U1pge/7cvKi83gE+9Q14NBYxnH9PGf3HGM0uFiajn5y9xA2dxhkUSSaBd1qiGv/R6MeG1+/zndyaIRH7w==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "chalk": "^4.0.0" + }, + "peerDependencies": { + "@jest/reporters": ">=25.1.0", + "jest-message-util": ">=25.1.0" + } + }, "node_modules/jest-diff": { "version": "29.6.4", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.4.tgz", diff --git a/package.json b/package.json index 6f5c06aec8..a2fcb9e98d 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", "@edx/frontend-component-footer": "12.2.1", "@edx/frontend-component-header": "4.6.0", - "@edx/frontend-lib-special-exams": "2.29.0", "@edx/frontend-lib-learning-assistant": "^1.24.0", + "@edx/frontend-lib-special-exams": "2.29.0", "@edx/frontend-platform": "5.5.2", "@edx/openedx-atlas": "^0.6.0", "@edx/paragon": "20.46.0", @@ -80,6 +80,7 @@ "es-check": "6.2.1", "husky": "7.0.4", "jest": "29.5.0", + "jest-console-group-reporter": "^1.0.1", "rosie": "2.1.1" } } diff --git a/src/course-home/courseware-search/CoursewareSearch.jsx b/src/course-home/courseware-search/CoursewareSearch.jsx index 5fb8c9742c..a068d463f3 100644 --- a/src/course-home/courseware-search/CoursewareSearch.jsx +++ b/src/course-home/courseware-search/CoursewareSearch.jsx @@ -103,7 +103,7 @@ const CoursewareSearch = ({ intl, ...sectionProps }) => {
-

{intl.formatMessage(messages.searchModuleTitle)}

+

{intl.formatMessage(messages.searchModuleTitle)}

show={showCompletePopover} placement="top" overlay={( -