diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 12eed48c50..5822d446b1 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -86,6 +86,7 @@ jobs: name: unit-tests-${{ matrix.node-version }} path: ./coverage/unit/lcov.info - name: Run ESM Unit Tests + if: matrix.node-version != '20.x' run: npm run unit:esm - name: Archive ESM Unit Test Coverage uses: actions/upload-artifact@v3 @@ -139,8 +140,8 @@ jobs: run: npm ci - name: Run Docker Services run: npm run services - - name: Run Versioned Tests (npm v7 / Node 16+) - run: TEST_CHILD_TIMEOUT=600000 npm run versioned:npm7 + - name: Run Versioned Tests + run: TEST_CHILD_TIMEOUT=600000 npm run versioned env: VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }} JOBS: 4 # 2 per CPU seems to be the sweet spot in GHA (July 2022) diff --git a/test/integration/logger.tap.js b/test/integration/logger.tap.js index 2cc2ad44d3..6d562aa515 100644 --- a/test/integration/logger.tap.js +++ b/test/integration/logger.tap.js @@ -11,6 +11,7 @@ const tap = require('tap') const rimraf = require('rimraf') const util = require('util') const exec = util.promisify(require('child_process').exec) +const { isSupportedVersion } = require('../lib/agent_helper') const DIRNAME = 'XXXNOCONFTEST' @@ -56,10 +57,13 @@ tap.test('logger', function (t) { tap.test('Logger output', (t) => { t.autoend() - const execArgs = [ - { opt: '-r', arg: '../../../index.js' }, - { opt: '--experimental-loader', arg: '../../../esm-loader.mjs' } - ] + const execArgs = [{ opt: '-r', arg: '../../../index.js' }] + + // TODO: add back to array when we fix ESM loader + if (!isSupportedVersion('v19.0.0')) { + execArgs.push({ opt: '--experimental-loader', arg: '../../../esm-loader.mjs' }) + } + for (const pair of execArgs) { const { opt, arg } = pair t.test(`Check for ${opt} in logger output at debug level`, async (t) => { diff --git a/test/lib/agent_helper.js b/test/lib/agent_helper.js index 268bdcfe1e..88ec6ae182 100644 --- a/test/lib/agent_helper.js +++ b/test/lib/agent_helper.js @@ -19,6 +19,7 @@ const Transaction = require('../../lib/transaction') const symbols = require('../../lib/symbols') const http = require('http') const https = require('https') +const semver = require('semver') const KEYPATH = path.join(__dirname, 'test-key.key') const CERTPATH = path.join(__dirname, 'self-signed-test-certificate.crt') @@ -686,5 +687,13 @@ const helper = (module.exports = { : original[symbols.original] } return original + }, + /** + * Util that checks if current node version is supported + * @param {string} version semver version string + * @returns {boolean} if version is supported + */ + isSupportedVersion(version) { + return semver.gt(process.version, version) } }) diff --git a/test/unit/environment.test.js b/test/unit/environment.test.js index 12b7bf6dfa..f761eb5059 100644 --- a/test/unit/environment.test.js +++ b/test/unit/environment.test.js @@ -15,6 +15,7 @@ const path = require('path') const fs = require('fs/promises') const spawn = require('child_process').spawn const environment = require('../../lib/environment') +const { isSupportedVersion } = require('../lib/agent_helper') function find(settings, name) { const items = settings.filter(function (candidate) { @@ -136,10 +137,8 @@ tap.test('the environment scraper', (t) => { t.end() }) - // TODO: expected, waiting for https://github.com/newrelic/node-newrelic/pull/1705 - // to merge down before applying to appropriate skip - /*t.test('without process.config', (t) => { ->>>>>>> 573d9fb80 (chore: updated unit tests to get them working with node 20) + // TODO: remove tests when we drop support for node 18 + t.test('without process.config', { skip: isSupportedVersion('v19.0.0') }, (t) => { let conf = null t.before(() => { @@ -149,6 +148,7 @@ tap.test('the environment scraper', (t) => { * TODO: Augmenting process.config has been deprecated in Node 16. * When fully disabled we may no-longer be able to test but also may no-longer need to. * https://nodejs.org/api/deprecations.html#DEP0150 + */ process.config = null return reloadEnvironment() }) @@ -183,7 +183,6 @@ tap.test('the environment scraper', (t) => { }) t.end() }) - */ t.test('should have built a flattened package list', (t) => { const packages = find(settings, 'Packages') @@ -219,10 +218,10 @@ tap.test('the environment scraper', (t) => { t.end() }) - // TODO: this will no longer work in Node 20 - /* it('should resolve refresh where deps and deps of deps are symlinked to each other', async function () { + // TODO: remove this test when we drop support for node 18 t.test( 'should resolve refresh where deps and deps of deps are symlinked to each other', + { skip: isSupportedVersion('v19.0.0') }, async (t) => { process.config.variables.node_prefix = path.join(__dirname, '../lib/example-deps') const data = await environment.getJSON() @@ -232,7 +231,6 @@ tap.test('the environment scraper', (t) => { t.end() } ) - */ t.test('should not crash when given a file in NODE_PATH', (t) => { const env = { diff --git a/test/unit/instrumentation/http/synthetics.test.js b/test/unit/instrumentation/http/synthetics.test.js index cd3e338af7..ecb1e128fb 100644 --- a/test/unit/instrumentation/http/synthetics.test.js +++ b/test/unit/instrumentation/http/synthetics.test.js @@ -66,8 +66,6 @@ tap.test('synthetics outbound header', (t) => { }) }) - // TODO: The server doesn't seem to be getting closed - // before the test listens on the next t.test('should be propagated if on tx', (t) => { helper.runInTransaction(agent, function (transaction) { transaction.syntheticsData = SYNTHETICS_DATA diff --git a/test/versioned/esm-package/package.json b/test/versioned/esm-package/package.json index 81f68e1f85..01a3832b32 100644 --- a/test/versioned/esm-package/package.json +++ b/test/versioned/esm-package/package.json @@ -7,7 +7,7 @@ "tests": [ { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "parse-json": "6.0.2" diff --git a/test/versioned/express-esm/package.json b/test/versioned/express-esm/package.json index 61c7fa2bbc..ce64cb3024 100644 --- a/test/versioned/express-esm/package.json +++ b/test/versioned/express-esm/package.json @@ -6,7 +6,7 @@ "tests": [ { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "express": ">=4.6.0", diff --git a/test/versioned/grpc-esm/package.json b/test/versioned/grpc-esm/package.json index 6f364d0902..2a7ef29ea8 100644 --- a/test/versioned/grpc-esm/package.json +++ b/test/versioned/grpc-esm/package.json @@ -6,7 +6,7 @@ "tests": [ { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "@grpc/grpc-js": ">=1.4.0" diff --git a/test/versioned/mongodb-esm/package.json b/test/versioned/mongodb-esm/package.json index 9b58ac5a9d..ffc5d2e6af 100644 --- a/test/versioned/mongodb-esm/package.json +++ b/test/versioned/mongodb-esm/package.json @@ -6,7 +6,7 @@ "tests": [ { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "mongodb": ">=2.1 < 4.0.0 || >= 4.1.4 < 5" diff --git a/test/versioned/pg-esm/package.json b/test/versioned/pg-esm/package.json index 60c6e2ec19..0661f06903 100644 --- a/test/versioned/pg-esm/package.json +++ b/test/versioned/pg-esm/package.json @@ -6,7 +6,7 @@ "tests": [ { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "pg": ">=8.2 <8.8", @@ -20,7 +20,7 @@ }, { "engines": { - "node": ">=16.12.0" + "node": ">=16.12.0 <20" }, "dependencies": { "pg": ">=8.8",