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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"inflection": "^3.0.2",
"markdown-table": "^3.0.4",
"openapi-to-postmanv2": "5.2.0",
"parquet-wasm": "^0.6.1"
"parquet-wasm": "^0.7.0"
},
"devDependencies": {
"@babel/core": "^7.28.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { describe, expect, it } from '@jest/globals';
import { spawnSync } from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

/**
* Integration test for runMetricCollection.js script
*
* This test ensures that the script can be run without syntax errors,
* which helps catch issues like:
* - Missing or incorrectly exported dependencies (e.g., parquet-wasm exports)
* - Import/export syntax errors
* - Module resolution problems
*/
describe('tools/spectral/ipa/metrics/scripts/runMetricCollection.js', () => {
it('should run without import/syntax errors', () => {
const scriptPath = path.join(__dirname, '../../metrics/scripts/runMetricCollection.js');

// Run the script with Node.js, providing a non-existent file path
// This will cause it to fail early before doing any real work
const result = spawnSync('node', [scriptPath, '/nonexistent/path/to/spec.json'], {
encoding: 'utf8',
timeout: 10000,
});

// The script will fail because the file doesn't exist,
// but it should NOT fail with a SyntaxError about missing exports
const output = result.stdout + result.stderr;

// Check that we don't have import/syntax errors
expect(output).not.toMatch(/SyntaxError.*does not provide an export named/);
expect(output).not.toMatch(/SyntaxError.*Unexpected token/);

// We expect it to fail due to missing files (either OAS file or collector results)
// This proves the imports worked correctly
expect(output).toMatch(/ENOENT|Could not find/);
});
});
4 changes: 2 additions & 2 deletions tools/spectral/ipa/metrics/scripts/runMetricCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs';
import path from 'path';
import { spawnSync } from 'child_process';
import spectral from '@stoplight/spectral-core';
import { Compression, Table, writeParquet, WriterPropertiesBuilder } from 'parquet-wasm';
import { Table, writeParquet, WriterPropertiesBuilder } from 'parquet-wasm/esm/parquet_wasm.js';
import { tableFromJSON, tableToIPC } from 'apache-arrow';
import config from '../config.js';
import { runMetricCollectionJob } from '../metricCollection.js';
Expand Down Expand Up @@ -58,7 +58,7 @@ runMetricCollectionJob(
const wasmTable = Table.fromIPCStream(tableToIPC(table, 'stream'));
const parquetUint8Array = writeParquet(
wasmTable,
new WriterPropertiesBuilder().setCompression(Compression.GZIP).build()
new WriterPropertiesBuilder().setCompression(2).build() // 2 = GZIP compression
);
fs.writeFileSync(config.defaultMetricCollectionResultsFilePath, parquetUint8Array);
fs.writeFileSync(path.join(config.defaultOutputsDir, 'warning-count.txt'), results.warnings.count.toString());
Expand Down
Loading