From 471488f47ec3b28643c760a9915432ceb6db4c1c Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 2 Jun 2024 13:00:48 +0200 Subject: [PATCH 1/8] test: Test 240+ popular npm packages --- .gitignore | 3 +- package.json | 1 + test/check-exports/test.mjs | 101 ++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 test/check-exports/test.mjs diff --git a/.gitignore b/.gitignore index 2a6e3f9..470ad45 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ package-lock.json yarn.lock node_modules coverage -.DS_Store \ No newline at end of file +.DS_Store +test/check-exports/package.json diff --git a/package.json b/package.json index e1e0802..2ac6c04 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "test": "c8 --reporter lcov --check-coverage --lines 50 imhotap --files test/{hook,low-level,other,get-esm-exports}/*", + "test:e2e": "node test/check-exports/test.mjs", "test:ts": "c8 --reporter lcov imhotap --files test/typescript/*.test.mts", "coverage": "c8 --reporter html imhotap --files test/{hook,low-level,other,get-esm-exports}/* && echo '\nNow open coverage/index.html\n'", "lint": "eslint .", diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs new file mode 100644 index 0000000..90fc4a1 --- /dev/null +++ b/test/check-exports/test.mjs @@ -0,0 +1,101 @@ +import { spawnSync } from 'child_process' +import { deepStrictEqual } from 'assert' +import { dirname, resolve } from 'path' +import { fileURLToPath } from 'url' + +const cwd = dirname(fileURLToPath(import.meta.url)) +const hook = resolve(cwd, '..', '..', 'hook.mjs') + +function getExports (name, loader) { + const args = ['--input-type=module', '--no-warnings', '-e', `import * as lib from '${name}'; console.log(JSON.stringify(Object.keys(lib)))`] + if (loader) args.push(loader) + const out = spawnSync(process.execPath, args, { cwd }) + if (out.status !== 0) { + console.error(out.stderr.toString()) + throw new Error() + } + const stdout = out.stdout.toString() + return JSON.parse(stdout).sort() +} + +function testLib (name) { + try { + const expected = getExports(name) + const actual = getExports(name, `--experimental-loader=${hook}`) + deepStrictEqual(actual, expected, `Exports for ${name} are different`) + console.log(`✅ Exports for '${name}' match`) + } catch (err) { + console.error(`❌ Error getting exports for '${name}':`, err) + } +} + +function installLibs (names) { + spawnSync('npm', ['init', '-y'], { cwd }) + spawnSync('npm', ['install', ...names], { cwd }) +} + +const modules = [ + 'ansi-styles', 'semver', 'supports-color', 'chalk', 'has-flag', 'debug', + 'tslib', 'color-convert', 'ms', 'color-name', 'lru-cache', 'minimatch', + 'strip-ansi', 'source-map', 'ansi-regex', 'glob', 'readable-stream', + 'commander', 'yallist', 'string-width', 'escape-string-regexp', + 'brace-expansion', 'find-up', 'p-locate', 'locate-path', 'wrap-ansi', + 'p-limit', 'safe-buffer', 'kind-of', 'minipass', 'uuid', 'string_decoder', + 'ajv', 'emoji-regex', 'isarray', 'react-is', 'fs-extra', + 'is-fullwidth-code-point', 'get-stream', 'json-schema-traverse', + 'yargs-parser', 'glob-parent', 'yargs', 'rimraf', 'acorn', 'which', + 'estraverse', 'js-yaml', 'path-exists', 'argparse', 'pretty-format', + 'resolve-from', 'cliui', 'schema-utils', 'globals', 'camelcase', 'execa', + 'punycode', 'path-key', 'signal-exit', 'inherits', 'resolve', 'mkdirp', + 'is-stream', 'ws', 'universalify', 'qs', 'slash', 'json5', 'iconv-lite', + 'form-data', 'is-number', 'webidl-conversions', 'eslint-visitor-keys', + '@jest/types', 'postcss', 'make-dir', 'pify', 'cross-spawn', 'braces', + 'whatwg-url', 'fill-range', 'eslint-scope', 'tr46', 'micromatch', + 'convert-source-map', 'define-property', 'agent-base', 'shebang-regex', + 'shebang-command', 'mimic-fn', 'globby', 'npm-run-path', 'mime', + '@babel/code-frame', 'extend-shallow', 'to-regex-range', 'onetime', + 'https-proxy-agent', 'y18n', 'buffer', 'strip-bom', 'is-glob', + 'doctrine', 'picocolors', 'pkg-dir', '@babel/types', + 'regenerator-runtime', 'human-signals', '@jridgewell/trace-mapping', + 'ignore', 'jsesc', 'parse-json', 'jest-worker', 'graceful-fs', + 'jest-util', 'jsonfile', 'normalize-path', 'strip-json-comments', + 'cosmiconfig', 'minimist', 'path-type', '@babel/parser', 'balanced-match', + 'picomatch', 'typescript', 'isexe', 'statuses', 'entities', 'bytes', + 'node-fetch', 'http-errors', '@babel/highlight', + '@babel/helper-validator-identifier', 'function-bind', + 'async', 'sprintf-js', '@babel/generator', 'is-extendable', + 'get-intrinsic', 'lodash', 'mime-db', 'source-map-support', 'mime-types', + 'is-arrayish', '@babel/core', 'once', 'anymatch', 'depd', + 'hosted-git-info', 'path-to-regexp', 'axios', 'is-core-module', + '@babel/template', 'cookie', 'write-file-atomic', 'js-tokens', + '@typescript-eslint/typescript-estree', '@typescript-eslint/types', + 'object-inspect', 'wrappy', 'is-extglob', 'chokidar', + '@typescript-eslint/visitor-keys', 'call-bind', 'loader-utils', + 'browserslist', 'http-proxy-agent', 'fast-glob', 'concat-map', + 'inflight', 'ajv-keywords', 'ansi-escapes', 'ci-info', 'fast-deep-equal', + 'caniuse-lite', 'fs.realpath', '@jridgewell/gen-mapping', 'setprototypeof', + 'strip-final-newline', 'optionator', 'path-is-absolute', '@babel/traverse', + 'core-util-is', 'has-symbols', 'yocto-queue', 'p-try', + 'electron-to-chromium', '@smithy/smithy-client', 'yaml', 'ini', + '@babel/helper-plugin-utils', 'jest-get-type', 'type-check', 'levn', + 'is-descriptor', 'prelude-ls', 'slice-ansi', + '@typescript-eslint/scope-manager', 'isobject', 'esprima', + '@babel/helper-split-export-declaration', 'callsites', 'readdirp', + 'escalade', 'import-fresh', 'get-caller-file', '@jridgewell/sourcemap-codec', + 'acorn-walk', 'rxjs', 'ieee754', 'is-plain-obj', + 'istanbul-lib-instrument', '@babel/helper-module-imports', 'side-channel', + 'normalize-package-data', 'is-plain-object', 'util-deprecate', + '@jridgewell/resolve-uri', 'follow-redirects', 'array-union', + 'json-parse-even-better-errors', 'path-parse', 'has-property-descriptors', + 'uri-js', 'safer-buffer', '@babel/helpers', 'on-finished', + '@babel/helper-function-name', 'p-map', 'postcss-value-parser', 'indent-string', + '@babel/helper-module-transforms', 'object-assign', 'delayed-stream', + '@nodelib/fs.stat', 'require-directory', 'diff', 'parse5', + 'asynckit', 'tmp', 'combined-stream'] + +console.log(`📦 Installing ${modules.length} libraries...`) +installLibs(modules) + +for (const mod of modules) { + testLib(mod) +} From 41bc8119c31bf3713c7e7b9a49629d01c9bb9e63 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 2 Jun 2024 13:12:13 +0200 Subject: [PATCH 2/8] Non-zero exit code on failure --- test/check-exports/test.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs index 90fc4a1..a7f5411 100644 --- a/test/check-exports/test.mjs +++ b/test/check-exports/test.mjs @@ -6,6 +6,8 @@ import { fileURLToPath } from 'url' const cwd = dirname(fileURLToPath(import.meta.url)) const hook = resolve(cwd, '..', '..', 'hook.mjs') +let errored = false + function getExports (name, loader) { const args = ['--input-type=module', '--no-warnings', '-e', `import * as lib from '${name}'; console.log(JSON.stringify(Object.keys(lib)))`] if (loader) args.push(loader) @@ -26,6 +28,7 @@ function testLib (name) { console.log(`✅ Exports for '${name}' match`) } catch (err) { console.error(`❌ Error getting exports for '${name}':`, err) + errored = true } } @@ -99,3 +102,8 @@ installLibs(modules) for (const mod of modules) { testLib(mod) } + +if (errored) { + console.error('❌ Some tests failed') + process.exit(1) +} From 9f52568456ed6950c91c9ddada0779c3560b7567 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 17 Jun 2024 14:58:09 +0200 Subject: [PATCH 3/8] PR feedback and run in CI --- .github/workflows/ci.yml | 12 ++ test/check-exports/test.mjs | 345 ++++++++++++++++++++++++++++-------- 2 files changed, 286 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44577f3..82c8970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,3 +103,15 @@ jobs: - name: Verify Minimum Coverage Is Met run: > lcov --summary all_lcov.info | grep lines | cut -d' ' -f 4 | cut -d% -f 1 | xargs node -e "x=process.argv[1];console.log(x);assert(+x >= 90)" + + integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # We only test that exports match on a single node version because many of + # the libraries we test do not support older node versions + - uses: actions/setup-node@v4 + with: + node-version: '22.x' + - run: npm install + - run: npm run test:e2e diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs index a7f5411..e74eb09 100644 --- a/test/check-exports/test.mjs +++ b/test/check-exports/test.mjs @@ -6,7 +6,262 @@ import { fileURLToPath } from 'url' const cwd = dirname(fileURLToPath(import.meta.url)) const hook = resolve(cwd, '..', '..', 'hook.mjs') -let errored = false +const modules = [ + 'ansi-styles', + 'semver', + 'supports-color', + 'chalk', 'has-flag', + 'debug', + 'tslib', + 'color-convert', + 'ms', + 'color-name', + 'lru-cache', + 'minimatch', + 'strip-ansi', + 'source-map', + 'ansi-regex', + 'glob', + 'readable-stream', + 'commander', + 'yallist', + 'string-width', + 'escape-string-regexp', + 'brace-expansion', + 'find-up', + 'p-locate', + 'locate-path', + 'wrap-ansi', + 'p-limit', + 'safe-buffer', + 'kind-of', + 'minipass', + 'uuid', + 'string_decoder', + 'ajv', + 'emoji-regex', + 'isarray', + 'react-is', + 'fs-extra', + 'is-fullwidth-code-point', + 'get-stream', + 'json-schema-traverse', + 'yargs-parser', + 'glob-parent', + 'yargs', + 'rimraf', + 'acorn', + 'which', + 'estraverse', + 'js-yaml', + 'path-exists', + 'argparse', + 'pretty-format', + 'resolve-from', + 'cliui', + 'schema-utils', + 'globals', + 'camelcase', + 'execa', + 'punycode', + 'path-key', + 'signal-exit', + 'inherits', + 'resolve', + 'mkdirp', + 'is-stream', + 'ws', + 'universalify', + 'qs', + 'slash', + 'json5', + 'iconv-lite', + 'form-data', + 'is-number', + 'eslint-visitor-keys', + '@jest/types', + 'postcss', + 'make-dir', + 'pify', + 'cross-spawn', + 'braces', + 'whatwg-url', + 'fill-range', + 'eslint-scope', + 'tr46', + 'micromatch', + 'convert-source-map', + 'define-property', + 'agent-base', + 'shebang-regex', + 'shebang-command', + 'mimic-fn', + 'globby', + 'npm-run-path', + 'mime', + '@babel/code-frame', + 'extend-shallow', + 'to-regex-range', + 'onetime', + 'https-proxy-agent', + 'y18n', + 'buffer', + 'strip-bom', + 'is-glob', + 'doctrine', + 'picocolors', + 'pkg-dir', + '@babel/types', + 'regenerator-runtime', + 'human-signals', + '@jridgewell/trace-mapping', + 'ignore', + 'jsesc', + 'parse-json', + 'jest-worker', + 'graceful-fs', + 'jest-util', + 'jsonfile', + 'normalize-path', + 'strip-json-comments', + 'cosmiconfig', + 'minimist', + 'path-type', + '@babel/parser', + 'balanced-match', + 'picomatch', + 'typescript', + 'isexe', + 'statuses', + 'entities', + 'bytes', + 'node-fetch', + 'http-errors', + '@babel/highlight', + '@babel/helper-validator-identifier', + 'function-bind', + 'async', + 'sprintf-js', + '@babel/generator', + 'is-extendable', + 'get-intrinsic', + 'lodash', + 'mime-db', + 'source-map-support', + 'mime-types', + 'is-arrayish', + '@babel/core', + 'once', + 'anymatch', + 'depd', + 'hosted-git-info', + 'path-to-regexp', + 'axios', + 'is-core-module', + '@babel/template', + 'cookie', + 'write-file-atomic', + 'js-tokens', + '@typescript-eslint/typescript-estree', + '@typescript-eslint/types', + 'object-inspect', + 'wrappy', + 'is-extglob', + 'chokidar', + '@typescript-eslint/visitor-keys', + 'call-bind', + 'loader-utils', + 'browserslist', + 'http-proxy-agent', + 'fast-glob', + 'concat-map', + 'inflight', + 'ajv-keywords', + 'ansi-escapes', + 'ci-info', + 'fast-deep-equal', + 'caniuse-lite', + 'fs.realpath', + '@jridgewell/gen-mapping', + 'setprototypeof', + 'strip-final-newline', + 'optionator', + 'path-is-absolute', + '@babel/traverse', + 'core-util-is', + 'has-symbols', + 'yocto-queue', + 'p-try', + 'electron-to-chromium', + '@smithy/smithy-client', + 'yaml', + 'ini', + '@babel/helper-plugin-utils', + 'jest-get-type', + 'type-check', + 'levn', + 'is-descriptor', + 'prelude-ls', + 'slice-ansi', + '@typescript-eslint/scope-manager', + 'isobject', + 'esprima', + '@babel/helper-split-export-declaration', + 'callsites', + 'readdirp', + 'escalade', + 'import-fresh', + 'get-caller-file', + '@jridgewell/sourcemap-codec', + 'acorn-walk', + 'rxjs', + 'ieee754', + 'is-plain-obj', + 'istanbul-lib-instrument', + '@babel/helper-module-imports', + 'side-channel', + 'normalize-package-data', + 'is-plain-object', + '@jridgewell/resolve-uri', + 'follow-redirects', + 'array-union', + 'json-parse-even-better-errors', + 'path-parse', + 'has-property-descriptors', + 'uri-js', + 'safer-buffer', + '@babel/helpers', + 'on-finished', + '@babel/helper-function-name', + 'p-map', + 'postcss-value-parser', + 'indent-string', + '@babel/helper-module-transforms', + 'object-assign', + 'delayed-stream', + '@nodelib/fs.stat', + 'require-directory', + 'diff', + 'parse5', + 'asynckit', + 'tmp', + 'combined-stream', + 'express', + 'fastify', + '@hapi/hapi', + 'connect', + 'svelte', + '@sveltejs/kit', + 'next', + 'gatsby', + '@remix-run/node', + '@remix-run/react' +] + +function installLibs (names) { + spawnSync('npm', ['init', '-y'], { cwd }) + spawnSync('npm', ['install', ...names], { cwd }) +} function getExports (name, loader) { const args = ['--input-type=module', '--no-warnings', '-e', `import * as lib from '${name}'; console.log(JSON.stringify(Object.keys(lib)))`] @@ -14,93 +269,41 @@ function getExports (name, loader) { const out = spawnSync(process.execPath, args, { cwd }) if (out.status !== 0) { console.error(out.stderr.toString()) - throw new Error() + throw new Error(`Getting exports returned non-zero exit code '${name}'`) } const stdout = out.stdout.toString() return JSON.parse(stdout).sort() } -function testLib (name) { +const NPM_LIST_SEMVER_PARSE = /└──.*@((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)/ + +function getVersion(name) { + const result = spawnSync('npm', ['list', name, '--depth', '0'], { cwd }) + const stdout = result.output.toString(); + const [,version] = stdout.match(NPM_LIST_SEMVER_PARSE) + return version +} + +function testLib(name) { + const version = getVersion(name) try { const expected = getExports(name) const actual = getExports(name, `--experimental-loader=${hook}`) deepStrictEqual(actual, expected, `Exports for ${name} are different`) - console.log(`✅ Exports for '${name}' match`) + console.log(`✅ Exports for ${name}@${version} match`) + return false } catch (err) { - console.error(`❌ Error getting exports for '${name}':`, err) - errored = true + console.error(`❌ Error getting exports for ${name}@${version}:`, err) + return true } } -function installLibs (names) { - spawnSync('npm', ['init', '-y'], { cwd }) - spawnSync('npm', ['install', ...names], { cwd }) -} - -const modules = [ - 'ansi-styles', 'semver', 'supports-color', 'chalk', 'has-flag', 'debug', - 'tslib', 'color-convert', 'ms', 'color-name', 'lru-cache', 'minimatch', - 'strip-ansi', 'source-map', 'ansi-regex', 'glob', 'readable-stream', - 'commander', 'yallist', 'string-width', 'escape-string-regexp', - 'brace-expansion', 'find-up', 'p-locate', 'locate-path', 'wrap-ansi', - 'p-limit', 'safe-buffer', 'kind-of', 'minipass', 'uuid', 'string_decoder', - 'ajv', 'emoji-regex', 'isarray', 'react-is', 'fs-extra', - 'is-fullwidth-code-point', 'get-stream', 'json-schema-traverse', - 'yargs-parser', 'glob-parent', 'yargs', 'rimraf', 'acorn', 'which', - 'estraverse', 'js-yaml', 'path-exists', 'argparse', 'pretty-format', - 'resolve-from', 'cliui', 'schema-utils', 'globals', 'camelcase', 'execa', - 'punycode', 'path-key', 'signal-exit', 'inherits', 'resolve', 'mkdirp', - 'is-stream', 'ws', 'universalify', 'qs', 'slash', 'json5', 'iconv-lite', - 'form-data', 'is-number', 'webidl-conversions', 'eslint-visitor-keys', - '@jest/types', 'postcss', 'make-dir', 'pify', 'cross-spawn', 'braces', - 'whatwg-url', 'fill-range', 'eslint-scope', 'tr46', 'micromatch', - 'convert-source-map', 'define-property', 'agent-base', 'shebang-regex', - 'shebang-command', 'mimic-fn', 'globby', 'npm-run-path', 'mime', - '@babel/code-frame', 'extend-shallow', 'to-regex-range', 'onetime', - 'https-proxy-agent', 'y18n', 'buffer', 'strip-bom', 'is-glob', - 'doctrine', 'picocolors', 'pkg-dir', '@babel/types', - 'regenerator-runtime', 'human-signals', '@jridgewell/trace-mapping', - 'ignore', 'jsesc', 'parse-json', 'jest-worker', 'graceful-fs', - 'jest-util', 'jsonfile', 'normalize-path', 'strip-json-comments', - 'cosmiconfig', 'minimist', 'path-type', '@babel/parser', 'balanced-match', - 'picomatch', 'typescript', 'isexe', 'statuses', 'entities', 'bytes', - 'node-fetch', 'http-errors', '@babel/highlight', - '@babel/helper-validator-identifier', 'function-bind', - 'async', 'sprintf-js', '@babel/generator', 'is-extendable', - 'get-intrinsic', 'lodash', 'mime-db', 'source-map-support', 'mime-types', - 'is-arrayish', '@babel/core', 'once', 'anymatch', 'depd', - 'hosted-git-info', 'path-to-regexp', 'axios', 'is-core-module', - '@babel/template', 'cookie', 'write-file-atomic', 'js-tokens', - '@typescript-eslint/typescript-estree', '@typescript-eslint/types', - 'object-inspect', 'wrappy', 'is-extglob', 'chokidar', - '@typescript-eslint/visitor-keys', 'call-bind', 'loader-utils', - 'browserslist', 'http-proxy-agent', 'fast-glob', 'concat-map', - 'inflight', 'ajv-keywords', 'ansi-escapes', 'ci-info', 'fast-deep-equal', - 'caniuse-lite', 'fs.realpath', '@jridgewell/gen-mapping', 'setprototypeof', - 'strip-final-newline', 'optionator', 'path-is-absolute', '@babel/traverse', - 'core-util-is', 'has-symbols', 'yocto-queue', 'p-try', - 'electron-to-chromium', '@smithy/smithy-client', 'yaml', 'ini', - '@babel/helper-plugin-utils', 'jest-get-type', 'type-check', 'levn', - 'is-descriptor', 'prelude-ls', 'slice-ansi', - '@typescript-eslint/scope-manager', 'isobject', 'esprima', - '@babel/helper-split-export-declaration', 'callsites', 'readdirp', - 'escalade', 'import-fresh', 'get-caller-file', '@jridgewell/sourcemap-codec', - 'acorn-walk', 'rxjs', 'ieee754', 'is-plain-obj', - 'istanbul-lib-instrument', '@babel/helper-module-imports', 'side-channel', - 'normalize-package-data', 'is-plain-object', 'util-deprecate', - '@jridgewell/resolve-uri', 'follow-redirects', 'array-union', - 'json-parse-even-better-errors', 'path-parse', 'has-property-descriptors', - 'uri-js', 'safer-buffer', '@babel/helpers', 'on-finished', - '@babel/helper-function-name', 'p-map', 'postcss-value-parser', 'indent-string', - '@babel/helper-module-transforms', 'object-assign', 'delayed-stream', - '@nodelib/fs.stat', 'require-directory', 'diff', 'parse5', - 'asynckit', 'tmp', 'combined-stream'] - console.log(`📦 Installing ${modules.length} libraries...`) installLibs(modules) +let errored = false for (const mod of modules) { - testLib(mod) + errored += testLib(mod) } if (errored) { From 246719bcdd72479af875483f23c33af07a62bbaa Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 17 Jun 2024 15:24:42 +0200 Subject: [PATCH 4/8] lint --- test/check-exports/test.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs index e74eb09..70fd026 100644 --- a/test/check-exports/test.mjs +++ b/test/check-exports/test.mjs @@ -277,14 +277,14 @@ function getExports (name, loader) { const NPM_LIST_SEMVER_PARSE = /└──.*@((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)/ -function getVersion(name) { +function getVersion (name) { const result = spawnSync('npm', ['list', name, '--depth', '0'], { cwd }) - const stdout = result.output.toString(); - const [,version] = stdout.match(NPM_LIST_SEMVER_PARSE) + const stdout = result.output.toString() + const [, version] = stdout.match(NPM_LIST_SEMVER_PARSE) return version } -function testLib(name) { +function testLib (name) { const version = getVersion(name) try { const expected = getExports(name) From 5608199176383ac654785f22b0598d59a0b48b4a Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 18 Jun 2024 15:44:06 +0200 Subject: [PATCH 5/8] better array names --- test/check-exports/test.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs index 70fd026..a6909d7 100644 --- a/test/check-exports/test.mjs +++ b/test/check-exports/test.mjs @@ -6,7 +6,7 @@ import { fileURLToPath } from 'url' const cwd = dirname(fileURLToPath(import.meta.url)) const hook = resolve(cwd, '..', '..', 'hook.mjs') -const modules = [ +const mostPopular240NpmModules = [ 'ansi-styles', 'semver', 'supports-color', @@ -245,7 +245,10 @@ const modules = [ 'parse5', 'asynckit', 'tmp', - 'combined-stream', + 'combined-stream' +] + +const otherCommonModulesUsedWithInstrumentation = [ 'express', 'fastify', '@hapi/hapi', @@ -258,6 +261,8 @@ const modules = [ '@remix-run/react' ] +const modules = [...mostPopular240NpmModules, otherCommonModulesUsedWithInstrumentation] + function installLibs (names) { spawnSync('npm', ['init', '-y'], { cwd }) spawnSync('npm', ['install', ...names], { cwd }) From f2ae22333400a399a98cab32cc0be748f7cfa904 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 18 Jun 2024 16:06:00 +0200 Subject: [PATCH 6/8] ooopsie! --- test/check-exports/test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/check-exports/test.mjs b/test/check-exports/test.mjs index a6909d7..2c7b5d1 100644 --- a/test/check-exports/test.mjs +++ b/test/check-exports/test.mjs @@ -261,7 +261,7 @@ const otherCommonModulesUsedWithInstrumentation = [ '@remix-run/react' ] -const modules = [...mostPopular240NpmModules, otherCommonModulesUsedWithInstrumentation] +const modules = [...mostPopular240NpmModules, ...otherCommonModulesUsedWithInstrumentation] function installLibs (names) { spawnSync('npm', ['init', '-y'], { cwd }) From 64c18680045286c1e0ebaae3f0988c458b4e6318 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 18 Jun 2024 16:30:00 +0200 Subject: [PATCH 7/8] PR code review suggestion Co-authored-by: James Sumners --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82c8970..811a437 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,6 @@ jobs: # the libraries we test do not support older node versions - uses: actions/setup-node@v4 with: - node-version: '22.x' + node-version: 'lts' - run: npm install - run: npm run test:e2e From b0461813201d29c22284fb65380169be6a6a1498 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sat, 29 Jun 2024 13:31:04 +0200 Subject: [PATCH 8/8] Use `lts/*` for integration tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 811a437..304d179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,6 @@ jobs: # the libraries we test do not support older node versions - uses: actions/setup-node@v4 with: - node-version: 'lts' + node-version: 'lts/*' - run: npm install - run: npm run test:e2e