diff --git a/package-lock.json b/package-lock.json index 87634910cc..4f03a56b18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,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", @@ -10581,9 +10581,9 @@ } }, "node_modules/parquet-wasm": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/parquet-wasm/-/parquet-wasm-0.6.1.tgz", - "integrity": "sha512-wTM/9Y4EHny8i0qgcOlL9UHsTXftowwCqDsAD8axaZbHp0Opp3ue8oxexbzTVNhqBjFhyhLiU3MT0rnEYnYU0Q==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/parquet-wasm/-/parquet-wasm-0.7.0.tgz", + "integrity": "sha512-BYFzpSNs/Rl++dWuNgwNZTggI8y4ABdO1zblumULrXy/gkC8qCqw4O2l5tfRQHgfAEls50jamqwCFUnWT10QiA==", "license": "MIT OR Apache-2.0" }, "node_modules/parse-json": { diff --git a/package.json b/package.json index fb24097bbd..bc45da76d4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tools/spectral/ipa/__tests__/metrics/runMetricCollection.test.js b/tools/spectral/ipa/__tests__/metrics/runMetricCollection.test.js new file mode 100644 index 0000000000..9db04343cc --- /dev/null +++ b/tools/spectral/ipa/__tests__/metrics/runMetricCollection.test.js @@ -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/); + }); +}); diff --git a/tools/spectral/ipa/metrics/scripts/runMetricCollection.js b/tools/spectral/ipa/metrics/scripts/runMetricCollection.js index d91f63a72b..ec6a92ebc8 100644 --- a/tools/spectral/ipa/metrics/scripts/runMetricCollection.js +++ b/tools/spectral/ipa/metrics/scripts/runMetricCollection.js @@ -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'; @@ -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());