From dc349396cb8322d3b9f3896486677315076bc76f Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 29 Oct 2025 09:38:52 +0200 Subject: [PATCH 1/5] chore: refactor tests and fix test links --- tests/e2e/commands.test.ts | 134 +++++++++--------- tests/e2e/helpers.ts | 5 +- .../nested/redocly.yaml | 2 +- .../apply-per-api-decorators/snapshot.txt | 4 +- .../apply-per-api-decorators/snapshot_3.txt | 6 +- tests/e2e/respect/max-steps/max-steps.test.ts | 4 +- tests/performance/{chart.mjs => chart.js} | 0 tests/performance/package.json | 2 +- 8 files changed, 79 insertions(+), 78 deletions(-) rename tests/performance/{chart.mjs => chart.js} (100%) diff --git a/tests/e2e/commands.test.ts b/tests/e2e/commands.test.ts index e78ab446d6..bba15e30f4 100644 --- a/tests/e2e/commands.test.ts +++ b/tests/e2e/commands.test.ts @@ -25,7 +25,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint']); test(file, async () => { - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); } @@ -36,7 +36,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint', 'museum.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -46,7 +46,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint', 'museum.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -56,7 +56,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint', 'museum.yaml', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -71,7 +71,7 @@ describe('E2E', () => { 'rule/operationId-casing', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); @@ -79,7 +79,7 @@ describe('E2E', () => { const testPath = join(__dirname, 'fixtures/constructor-property'); const args = getParams(indexEntryPoint, ['lint', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -89,7 +89,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -104,7 +104,7 @@ describe('E2E', () => { join(testPath, 'redocly.yaml'), ]); - const result = getCommandOutput(args, {}, {}); + const result = getCommandOutput(args, {}); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); @@ -114,7 +114,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['lint', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -129,7 +129,7 @@ describe('E2E', () => { join(testPath, 'redocly.yaml'), ]); - const result = getCommandOutput(args, {}, {}); + const result = getCommandOutput(args, {}); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); }); @@ -140,21 +140,21 @@ describe('E2E', () => { test('default-recommended-fallback', async () => { const testPath = join(folderPath, 'default-recommended-fallback'); const args = getParams(indexEntryPoint, ['lint', './openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('no-default-recommended-fallback', async () => { const testPath = join(folderPath, 'no-default-recommended-fallback'); const args = getParams(indexEntryPoint, ['lint', './openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('no-default-recommended-fallback-with-empty-config', async () => { const testPath = join(folderPath, 'no-default-recommended-fallback-with-empty-config'); const args = getParams(indexEntryPoint, ['lint', './openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -174,7 +174,7 @@ describe('E2E', () => { const passedArgs = getParams(indexEntryPoint, ['check-config', ...args]); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -187,7 +187,7 @@ describe('E2E', () => { '--config=nested/redocly.yaml', ]); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -197,7 +197,7 @@ describe('E2E', () => { const passedArgs = getParams(indexEntryPoint, ['check-config', '--config=redocly.yaml']); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -207,7 +207,7 @@ describe('E2E', () => { const passedArgs = getParams(indexEntryPoint, ['check-config', '--config=redocly.yaml']); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -217,7 +217,7 @@ describe('E2E', () => { const passedArgs = getParams(indexEntryPoint, ['check-config', '--config=redocly.yaml']); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -253,7 +253,7 @@ describe('E2E', () => { const passedArgs = getParams(indexEntryPoint, ['lint', ...args]); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -279,7 +279,7 @@ describe('E2E', () => { const args = [relativeInvalidOpenapiFile, `--lint-config=${option}`]; const passedArgs = getParams(indexEntryPoint, ['lint', ...args]); - const result = getCommandOutput(passedArgs, {}, { testPath }); + const result = getCommandOutput(passedArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, snapshot)); } @@ -292,7 +292,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['split', '../test-split/spec.json']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -301,7 +301,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['split', 'openapi.yaml', '--outDir=output']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -311,7 +311,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['split', file, '--outDir=output']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -321,7 +321,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['split', file, '--separator=/', '--outDir=output']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -331,7 +331,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['split', file, '--outDir=output']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -352,7 +352,7 @@ describe('E2E', () => { }); const lintArgs = getParams(indexEntryPoint, ['lint', 'output/openapi.json']); - const result = getCommandOutput(lintArgs, {}, { testPath }); + const result = getCommandOutput(lintArgs, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -372,7 +372,7 @@ describe('E2E', () => { }, }); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -397,7 +397,7 @@ describe('E2E', () => { test.each(testDirNames)('test: %s', async (dir) => { const testPath = join(__dirname, `join/${dir}`); const args = getParams(indexEntryPoint, ['join', ...entrypoints]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -405,7 +405,7 @@ describe('E2E', () => { test('three files one without servers', async () => { const testPath = join(__dirname, `join/three-files-one-without-servers`); const args = getParams(indexEntryPoint, ['join', ...entrypoints, 'baz.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -421,7 +421,7 @@ describe('E2E', () => { const testPath = join(__dirname, `join/${option.name}`); const argsWithOptions = [...entrypoints, ...[`--${option.name}=${option.value}`]]; const args = getParams(indexEntryPoint, ['join', ...argsWithOptions]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -430,7 +430,7 @@ describe('E2E', () => { test('with metadata', async () => { const testPath = join(__dirname, `join/with-metadata`); const args = getParams(indexEntryPoint, ['join', 'test.yaml', 'pet.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -470,7 +470,7 @@ describe('E2E', () => { ? [...parameters.entrypoints, ...[`-o=${parameters.output}`]] : parameters.entrypoints; const args = getParams(indexEntryPoint, ['join', ...argsWithOption]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, parameters.snapshot) ); @@ -500,7 +500,7 @@ describe('E2E', () => { const args = getParams(indexEntryPoint, ['bundle', ...entryPoints]); test(file, async () => { - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); } @@ -509,14 +509,14 @@ describe('E2E', () => { const testPath = join(folderPath, 'bundle-arazzo-valid-test-description'); const args = getParams(indexEntryPoint, ['bundle', 'museum.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('bundle should NOT be invoked IF no positional apis provided AND --output specified', async () => { const testPath = join(folderPath, 'bundle-no-output-without-inline-apis'); const args = getParams(indexEntryPoint, ['bundle', '--output=dist']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); @@ -526,7 +526,7 @@ describe('E2E', () => { const testPath = join(__dirname, `bundle/bundle-remove-unused-components/${type}`); const entryPoints = getEntrypoints(testPath); const args = [indexEntryPoint, 'bundle', '--remove-unused-components', ...entryPoints]; - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'remove-unused-components-snapshot.txt') ); @@ -541,7 +541,7 @@ describe('E2E', () => { ); const entryPoints = getEntrypoints(testPath); const args = [indexEntryPoint, 'bundle', ...entryPoints]; - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'remove-unused-components-snapshot.txt') ); @@ -556,7 +556,7 @@ describe('E2E', () => { ); const entryPoints = getEntrypoints(testPath); const args = [indexEntryPoint, 'bundle', ...entryPoints]; - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'without-remove-unused-components-snapshot.txt') ); @@ -571,7 +571,7 @@ describe('E2E', () => { 'bundle/bundle-remove-unused-components-from-api-config/oas2' ); const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'remove-unused-components-snapshot.txt') ); @@ -583,7 +583,7 @@ describe('E2E', () => { 'bundle/bundle-remove-unused-components-from-api-config/oas3' ); const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'remove-unused-components-snapshot.txt') ); @@ -597,7 +597,7 @@ describe('E2E', () => { 'bundle/bundle-remove-unused-components-from-api-config/oas2-without-option' ); const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'keep-unused-components-snapshot.txt') ); @@ -609,7 +609,7 @@ describe('E2E', () => { 'bundle/bundle-remove-unused-components-from-api-config/oas3-without-option' ); const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'keep-unused-components-snapshot.txt') ); @@ -621,7 +621,7 @@ describe('E2E', () => { 'bundle/bundle-remove-unused-components-from-api-config/oas3-with-decorator-off' ); const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'keep-unused-components-snapshot.txt') ); @@ -637,7 +637,7 @@ describe('E2E', () => { '--config=redocly.yaml', '--remove-unused-components', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot( join(testPath, 'keep-unused-components-snapshot.txt') ); @@ -649,7 +649,7 @@ describe('E2E', () => { const testPath = join(__dirname, `bundle/bundle-description-dereferenced`); const args = getParams(indexEntryPoint, ['bundle', 'test.yaml', '--dereferenced']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); @@ -657,7 +657,7 @@ describe('E2E', () => { const testPath = join(__dirname, `bundle/discriminator-mapping`); const args = getParams(indexEntryPoint, ['bundle', 'main.yaml', '--dereferenced']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); }); @@ -667,7 +667,7 @@ describe('E2E', () => { const testPath = join(__dirname, `bundle/bundle-description-long`); const args = getParams(indexEntryPoint, ['bundle', 'test.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); }); @@ -678,21 +678,21 @@ describe('E2E', () => { test('bundle should resolve $refs in preprocessors', async () => { const testPath = join(folderPath, 'resolve-refs-in-preprocessors'); const args = getParams(indexEntryPoint, ['bundle', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('lint should resolve $refs in preprocessors', async () => { const testPath = join(folderPath, 'resolve-refs-in-preprocessors'); const args = getParams(indexEntryPoint, ['lint', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); test('stat should print the correct summary with $refs in preprocessors', async () => { const testPath = join(folderPath, 'resolve-refs-in-preprocessors'); const args = getParams(indexEntryPoint, ['stats', 'openapi.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_3.txt')); }); @@ -703,7 +703,7 @@ describe('E2E', () => { 'openapi.yaml', '--config=plugin-config.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -714,14 +714,14 @@ describe('E2E', () => { 'openapi.yaml', '--config=plugin-config.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); test('apply a decorator to a specific api (without specifying the api)', async () => { const testPath = join(folderPath, 'apply-per-api-decorators'); const args = getParams(indexEntryPoint, ['bundle', '--config=nested/redocly.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); @@ -732,7 +732,7 @@ describe('E2E', () => { '--config=nested/redocly.yaml', 'test@fs', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_2.txt')); }); @@ -743,14 +743,14 @@ describe('E2E', () => { '--config=nested/redocly.yaml', 'test@external-url', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot_3.txt')); }); test('lint a specific api when alias is: specified (1); not specified (used the file path) (2)', async () => { const testPath = join(folderPath, 'apply-per-api-decorators'); const args1 = getParams(indexEntryPoint, ['lint', '--config=nested/redocly.yaml', 'test@fs']); - const result1 = getCommandOutput(args1, {}, { testPath }); + const result1 = getCommandOutput(args1, { testPath }); await expect(cleanupOutput(result1)).toMatchFileSnapshot(join(testPath, 'snapshot_4.txt')); const args2 = getParams(indexEntryPoint, [ @@ -758,7 +758,7 @@ describe('E2E', () => { '--config=nested/redocly.yaml', 'nested/openapi/main.yaml', ]); - const result2 = getCommandOutput(args2, {}, { testPath }); + const result2 = getCommandOutput(args2, { testPath }); await expect(cleanupOutput(result2)).toMatchFileSnapshot(join(testPath, 'snapshot_4.txt')); }); }); @@ -769,7 +769,7 @@ describe('E2E', () => { test('simple build-docs', async () => { const testPath = join(folderPath, 'simple-build-docs'); const args = getParams(indexEntryPoint, ['build-docs', 'pets.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); expect(existsSync(join(testPath, 'redoc-static.html'))).toEqual(true); @@ -783,7 +783,7 @@ describe('E2E', () => { '--config=nested/redocly.yaml', '-o=nested/redoc-static.html', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Found nested/redocly.yaml and using 'openapi' options @@ -808,7 +808,7 @@ describe('E2E', () => { '--theme.openapi.disableSearch', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Prerendering docs @@ -828,7 +828,7 @@ describe('E2E', () => { '--config=config.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Found config.yaml and using 'openapi' options @@ -848,7 +848,7 @@ describe('E2E', () => { 'alias', '--config=config-with-alias.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Found config-with-alias.yaml and using 'openapi' options @@ -868,7 +868,7 @@ describe('E2E', () => { 'openapi.yaml', '--config=config-with-alias.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Found config-with-alias.yaml and using 'openapi' options @@ -888,7 +888,7 @@ describe('E2E', () => { 'openapi.yaml', '--config=config-with-apis-and-root-option.yaml', ]); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); expect(cleanupOutput(result)).toMatchInlineSnapshot(` " Found config-with-apis-and-root-option.yaml and using 'openapi' options @@ -909,21 +909,21 @@ describe('E2E', () => { test('stats should produce correct output (stylish format)', async () => { const testPath = join(folderPath, 'stats-stylish'); const args = getParams(indexEntryPoint, ['stats', 'museum.yaml']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('stats should produce correct JSON output', async () => { const testPath = join(folderPath, 'stats-json'); const args = getParams(indexEntryPoint, ['stats', 'museum.yaml', '--format=json']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); test('stats should produce correct Markdown format', async () => { const testPath = join(folderPath, 'stats-markdown'); const args = getParams(indexEntryPoint, ['stats', 'museum.yaml', '--format=markdown']); - const result = getCommandOutput(args, {}, { testPath }); + const result = getCommandOutput(args, { testPath }); await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt')); }); }); diff --git a/tests/e2e/helpers.ts b/tests/e2e/helpers.ts index dd2428f752..be2e574d40 100644 --- a/tests/e2e/helpers.ts +++ b/tests/e2e/helpers.ts @@ -9,8 +9,7 @@ export function getParams(indexEntryPoint: string, args: string[] = []): string[ export function getCommandOutput( args: string[], - env?: Record, - options?: { testPath?: string } + options?: { env?: Record; testPath?: string } ) { const result = spawnSync('node', args, { encoding: 'utf-8', @@ -20,7 +19,7 @@ export function getCommandOutput( NODE_ENV: 'test', NO_COLOR: 'TRUE', FORCE_COLOR: '0', - ...env, + ...options?.env, }, cwd: options?.testPath, }); diff --git a/tests/e2e/miscellaneous/apply-per-api-decorators/nested/redocly.yaml b/tests/e2e/miscellaneous/apply-per-api-decorators/nested/redocly.yaml index fb96576469..3770df930b 100644 --- a/tests/e2e/miscellaneous/apply-per-api-decorators/nested/redocly.yaml +++ b/tests/e2e/miscellaneous/apply-per-api-decorators/nested/redocly.yaml @@ -7,7 +7,7 @@ apis: rules: info-license: error test@external-url: - root: https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml + root: https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml rules: info-contact: error plugins: diff --git a/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot.txt b/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot.txt index 6f4a91449f..b1274b2b34 100644 --- a/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot.txt +++ b/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot.txt @@ -15,5 +15,5 @@ components: bundling nested/openapi/main.yaml using configuration for api 'test@fs'... ๐Ÿ“ฆ Created a bundle for nested/openapi/main.yaml at stdout ms. ๐Ÿงน Removed 1 unused components. -bundling https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml using configuration for api 'test@external-url'... -๐Ÿ“ฆ Created a bundle for https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml at stdout ms. +bundling https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml using configuration for api 'test@external-url'... +๐Ÿ“ฆ Created a bundle for https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml at stdout ms. diff --git a/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot_3.txt b/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot_3.txt index 21e0eb54d4..0d85ad5460 100644 --- a/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot_3.txt +++ b/tests/e2e/miscellaneous/apply-per-api-decorators/snapshot_3.txt @@ -1,4 +1,4 @@ -[1] https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml:2:1 at #/info/contact +[1] https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml:2:1 at #/info/contact Info object should contain `contact` field. @@ -12,8 +12,8 @@ Error was generated by the info-contact rule. -validating https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml using lint rules for api 'test@external-url'... -https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/__tests__/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml: validated in ms +validating https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml using lint rules for api 'test@external-url'... +https://raw.githubusercontent.com/Redocly/redocly-cli/refs/heads/main/tests/e2e/miscellaneous/apply-per-api-decorators/nested/openapi/main.yaml: validated in ms โŒ Validation failed with 1 error. run `redocly lint --generate-ignore-file` to add all problems to the ignore file. diff --git a/tests/e2e/respect/max-steps/max-steps.test.ts b/tests/e2e/respect/max-steps/max-steps.test.ts index b01e4da130..37e70c9297 100644 --- a/tests/e2e/respect/max-steps/max-steps.test.ts +++ b/tests/e2e/respect/max-steps/max-steps.test.ts @@ -16,7 +16,9 @@ test('should quit an infinite loop on REDOCLY_CLI_RESPECT_MAX_STEPS', () => { ]); const result = getCommandOutput(args, { - REDOCLY_CLI_RESPECT_MAX_STEPS: '10', + env: { + REDOCLY_CLI_RESPECT_MAX_STEPS: '10', + }, }); expect(result).toMatchSnapshot(); diff --git a/tests/performance/chart.mjs b/tests/performance/chart.js similarity index 100% rename from tests/performance/chart.mjs rename to tests/performance/chart.js diff --git a/tests/performance/package.json b/tests/performance/package.json index 155b9f8d02..6b324fd63c 100644 --- a/tests/performance/package.json +++ b/tests/performance/package.json @@ -4,7 +4,7 @@ "description": "Test benchmark for Redocly CLI", "private": true, "scripts": { - "chart": "node chart.mjs > benchmark_chart.md", + "chart": "node chart.js > benchmark_chart.md", "make-test": "bash make-test-command.sh" }, "dependencies": { From 80c0fa6fe4b9be9cc058e49f9cbde4892adaad33 Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 29 Oct 2025 10:07:39 +0200 Subject: [PATCH 2/5] add coverage report --- .github/workflows/tests.yaml | 15 +++++---------- vitest.config.ts | 2 ++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8c397eb8ec..2c142c3b04 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,6 +26,11 @@ jobs: run: npm run typecheck - name: Unit Tests run: npm run unit + + - name: Coverage Report + if: always() # Generate the report if tests are failing + uses: davelosert/vitest-coverage-report-action@v2 + - name: E2E Tests run: npm run e2e @@ -48,16 +53,6 @@ jobs: - name: Definition test run: redocly lint resources/rebilly.yaml --format=stylish - coverage-report: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: 24 - cache: npm - # FIXME: add vitest coverage report (2.0) - code-style-check: runs-on: ubuntu-latest steps: diff --git a/vitest.config.ts b/vitest.config.ts index 770387607b..2d93897c6f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,6 +8,8 @@ const configExtension: { [key: string]: ViteUserConfig } = { include: ['packages/*/src/**/*.test.ts'], coverage: { enabled: true, + reporter: ['text', 'json-summary', 'json'], + reportOnFailure: true, include: [ 'packages/cli/src/**/*.ts', 'packages/core/src/**/*.ts', From a7c2986648198903fda3b8fb691e9ee2e407fc77 Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 29 Oct 2025 10:28:26 +0200 Subject: [PATCH 3/5] do not fail on error --- .github/workflows/tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2c142c3b04..bf0012708b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,7 +28,8 @@ jobs: run: npm run unit - name: Coverage Report - if: always() # Generate the report if tests are failing + if: always() # Also generate the report if tests are failing + continue-on-error: true uses: davelosert/vitest-coverage-report-action@v2 - name: E2E Tests From 2e8494ea0a0f3b56aca8733ebe6a00c2073be143 Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 29 Oct 2025 10:38:34 +0200 Subject: [PATCH 4/5] simulate error --- .github/workflows/tests.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index bf0012708b..0203f5bfd1 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,7 +30,10 @@ jobs: - name: Coverage Report if: always() # Also generate the report if tests are failing continue-on-error: true - uses: davelosert/vitest-coverage-report-action@v2 + # uses: davelosert/vitest-coverage-report-action@v2 + run: | + echo "This step is intentionally broken to throw an error" + exit 1 - name: E2E Tests run: npm run e2e From 62a76d5a987e3feeac6409a282288200dee3a916 Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Wed, 29 Oct 2025 10:46:24 +0200 Subject: [PATCH 5/5] move reporting back --- .github/workflows/tests.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0203f5bfd1..45be6e0d18 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,11 +29,8 @@ jobs: - name: Coverage Report if: always() # Also generate the report if tests are failing - continue-on-error: true - # uses: davelosert/vitest-coverage-report-action@v2 - run: | - echo "This step is intentionally broken to throw an error" - exit 1 + continue-on-error: true # Do not fail if there is an error during reporting + uses: davelosert/vitest-coverage-report-action@v2 - name: E2E Tests run: npm run e2e