From bde0f2ed5e8c9e8afd23565e804479b884af2f84 Mon Sep 17 00:00:00 2001 From: AgentHagu Date: Thu, 17 Apr 2025 22:33:38 +0800 Subject: [PATCH 1/4] Add info messages about expected errors --- packages/cli/test/functional/test.js | 14 ++++++++++++ .../unit/html/includePanelProcessor.test.ts | 22 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/packages/cli/test/functional/test.js b/packages/cli/test/functional/test.js index e76fdfb30d..77366ae900 100644 --- a/packages/cli/test/functional/test.js +++ b/packages/cli/test/functional/test.js @@ -6,6 +6,8 @@ const { compare } = require('./testUtil/compare'); const { cleanupConvert } = require('./testUtil/cleanup'); +const logger = require('../../../core/src/utils/logger'); + const { testSites, testConvertSites, @@ -29,6 +31,18 @@ const execOptions = { stdio: ['inherit', 'inherit', 'inherit'], }; +const expectedErrors = ["URLs are not allowed in the 'src' attribute"]; + +logger.info( + `The following ${ + expectedErrors.length === 1 ? 'error is' : 'errors are' + } expected to be thrown during the test run:`, +); + +expectedErrors.forEach((error, index) => { + logger.info(`${index + 1}: ${error}`); +}); + testSites.forEach((siteName) => { console.log(`Running ${siteName} tests`); try { diff --git a/packages/core/test/unit/html/includePanelProcessor.test.ts b/packages/core/test/unit/html/includePanelProcessor.test.ts index ef6b43f39f..5a9e255158 100644 --- a/packages/core/test/unit/html/includePanelProcessor.test.ts +++ b/packages/core/test/unit/html/includePanelProcessor.test.ts @@ -1,10 +1,32 @@ import path from 'path'; import { getNewDefaultNodeProcessor } from '../utils/utils'; +import * as logger from '../../../src/utils/logger'; const fs = require('fs'); jest.mock('fs'); +const expectedErrors = [ + 'No such segment \'#doesNotExist\' in file: markbind\\packages\\core\\include.md', + 'Cyclic reference detected.\nLast 5 files processed:\n' + + '\tmarkbind\\packages\\core\\index.md\n' + + '\tmarkbind\\packages\\core\\include.md\n' + + '\tmarkbind\\packages\\core\\index.md\n' + + '\tmarkbind\\packages\\core\\include.md\n' + + '\tmarkbind\\packages\\core\\index.md', +]; + +beforeAll(() => { + logger.info( + `The following ${ + expectedErrors.length === 1 ? 'error is' : 'errors are' + } expected to be thrown during the test run:`, + ); + expectedErrors.forEach((error, index) => { + logger.info(`${index + 1}: ${error}`); + }); +}); + afterEach(() => fs.vol.reset()); test('includeFile replaces with
', async () => { From 36a77a6242c23ce8754f11216ee7e308ade5ccf1 Mon Sep 17 00:00:00 2001 From: AgentHagu Date: Thu, 17 Apr 2025 22:33:56 +0800 Subject: [PATCH 2/4] Update developer guide workflow --- docs/devGuide/development/workflow.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/devGuide/development/workflow.md b/docs/devGuide/development/workflow.md index 49956afa25..e10404d8e8 100644 --- a/docs/devGuide/development/workflow.md +++ b/docs/devGuide/development/workflow.md @@ -188,8 +188,28 @@ To run the test script, use: `npm run test` If you only want to run tests for one of the packages (`packages/*`), simply switch into the appropriate directory and use `npm run test` as well! + + +When running `npm run test`, you may see errors in the console. Some of these errors are **expected** as part of the test cases. +Check the test logs for messages like: + +``` +info: The following 2 errors are expected to be thrown during the test run: +info: 1: No such segment '#doesNotExist' in file: markbind\packages\core\include.md +info: 2: Cyclic reference detected. +``` + +If an error is listed there, it's safe to ignore. + + #### Updating and writing tests + + +If you're adding tests that are expected to log errors to the console, make sure to **update the corresponding info messages** in the test logs. +This ensures that expected errors are properly listed and avoids confusion during test runs. + + ##### Updating unit tests Our unit tests perform fast, stable, and comprehensive checks on important behaviors of our classes and functions. Some existing tests can be found in the `packages/cli/test/unit` and `packages/core/test/unit` directory. Where appropriate, unit tests should be added/modified to account for any new/changed functionality. From 947d3338c1ef6e30a9efd96d723969fcf9393501 Mon Sep 17 00:00:00 2001 From: AgentHagu Date: Fri, 18 Apr 2025 11:58:18 +0800 Subject: [PATCH 3/4] Remove file path from info message --- docs/devGuide/development/workflow.md | 4 ++-- packages/core/test/unit/html/includePanelProcessor.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/devGuide/development/workflow.md b/docs/devGuide/development/workflow.md index e10404d8e8..705028b724 100644 --- a/docs/devGuide/development/workflow.md +++ b/docs/devGuide/development/workflow.md @@ -195,7 +195,7 @@ Check the test logs for messages like: ``` info: The following 2 errors are expected to be thrown during the test run: -info: 1: No such segment '#doesNotExist' in file: markbind\packages\core\include.md +info: 1: No such segment '#doesNotExist' in file info: 2: Cyclic reference detected. ``` @@ -206,7 +206,7 @@ If an error is listed there, it's safe to ignore. -If you're adding tests that are expected to log errors to the console, make sure to **update the corresponding info messages** in the test logs. +If you're adding tests that are expected to log new errors to the console, make sure to **update the corresponding info messages** in the test logs. This ensures that expected errors are properly listed and avoids confusion during test runs. diff --git a/packages/core/test/unit/html/includePanelProcessor.test.ts b/packages/core/test/unit/html/includePanelProcessor.test.ts index 5a9e255158..e0f5ae2aa7 100644 --- a/packages/core/test/unit/html/includePanelProcessor.test.ts +++ b/packages/core/test/unit/html/includePanelProcessor.test.ts @@ -7,7 +7,7 @@ const fs = require('fs'); jest.mock('fs'); const expectedErrors = [ - 'No such segment \'#doesNotExist\' in file: markbind\\packages\\core\\include.md', + 'No such segment \'#doesNotExist\' in file', 'Cyclic reference detected.\nLast 5 files processed:\n' + '\tmarkbind\\packages\\core\\index.md\n' + '\tmarkbind\\packages\\core\\include.md\n' From 8ab3c77d68b32d33c191c0365f53ddb62dbf2813 Mon Sep 17 00:00:00 2001 From: AgentHagu Date: Fri, 18 Apr 2025 16:49:21 +0800 Subject: [PATCH 4/4] Remove details for cyclic dependency --- packages/core/test/unit/html/includePanelProcessor.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/core/test/unit/html/includePanelProcessor.test.ts b/packages/core/test/unit/html/includePanelProcessor.test.ts index e0f5ae2aa7..98e487e843 100644 --- a/packages/core/test/unit/html/includePanelProcessor.test.ts +++ b/packages/core/test/unit/html/includePanelProcessor.test.ts @@ -8,12 +8,7 @@ jest.mock('fs'); const expectedErrors = [ 'No such segment \'#doesNotExist\' in file', - 'Cyclic reference detected.\nLast 5 files processed:\n' - + '\tmarkbind\\packages\\core\\index.md\n' - + '\tmarkbind\\packages\\core\\include.md\n' - + '\tmarkbind\\packages\\core\\index.md\n' - + '\tmarkbind\\packages\\core\\include.md\n' - + '\tmarkbind\\packages\\core\\index.md', + 'Cyclic reference detected.', ]; beforeAll(() => {