Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/devGuide/development/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
</box>

<box type="info" seamless>

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
info: 2: Cyclic reference detected.
```

If an error is listed there, it's safe to ignore.
</box>

#### Updating and writing tests

<box type="warning" seamless>

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.
</box>

##### 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.
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/test/functional/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { compare } = require('./testUtil/compare');

const { cleanupConvert } = require('./testUtil/cleanup');

const logger = require('../../../core/src/utils/logger');

const {
testSites,
testConvertSites,
Expand All @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions packages/core/test/unit/html/includePanelProcessor.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
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',
'Cyclic reference detected.',
];

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 <include> with <div>', async () => {
Expand Down