|
1 | 1 | import { NPMAuditReportV2 } from "audit-types";
|
2 | 2 | import { expect } from "chai";
|
| 3 | +import semver from "semver"; |
3 | 4 | import Allowlist from "../lib/allowlist";
|
4 | 5 | import { auditWithFullConfig, report } from "../lib/npm-auditer";
|
5 | 6 | import {
|
@@ -29,6 +30,12 @@ const reportNpmNone = untypedReportNpmNone as unknown as NPMAuditReportV2.Audit;
|
29 | 30 | const reportNpmSkipDevelopment =
|
30 | 31 | untypedReportNpmSkipDevelopment as unknown as NPMAuditReportV2.Audit;
|
31 | 32 |
|
| 33 | +const nodeVersion = process.version; |
| 34 | + |
| 35 | +function nodeVersionIsAtLeast(version: string) { |
| 36 | + return semver.gte(nodeVersion, version); |
| 37 | +} |
| 38 | + |
32 | 39 | function config(
|
33 | 40 | additions: Omit<Parameters<typeof baseConfig>[0], "package-manager">
|
34 | 41 | ) {
|
@@ -391,20 +398,21 @@ describe("npm7-auditer", () => {
|
391 | 398 | done();
|
392 | 399 | });
|
393 | 400 | });
|
394 |
| - it("fails with error code ECONNREFUSED on a live site with no registry", (done) => { |
395 |
| - auditWithFullConfig( |
396 |
| - config({ |
397 |
| - directory: testDirectory("npm-low"), |
398 |
| - levels: { low: true }, |
399 |
| - registry: "http://localhost", |
400 |
| - }) |
401 |
| - ) |
402 |
| - .catch((error) => { |
403 |
| - expect(error.message).to.include("ECONNREFUSED"); |
404 |
| - done(); |
405 |
| - }) |
406 |
| - .catch((error) => done(error)); |
407 |
| - }); |
| 401 | + semver.lt(nodeVersion, "20.0.0") && |
| 402 | + it("fails with error code ECONNREFUSED on a live site with no registry", (done) => { |
| 403 | + auditWithFullConfig( |
| 404 | + config({ |
| 405 | + directory: testDirectory("npm-low"), |
| 406 | + levels: { low: true }, |
| 407 | + registry: "http://localhost", |
| 408 | + }) |
| 409 | + ) |
| 410 | + .catch((error) => { |
| 411 | + expect(error.message).to.include("ECONNREFUSED"); |
| 412 | + done(); |
| 413 | + }) |
| 414 | + .catch((error) => done(error)); |
| 415 | + }); |
408 | 416 | it("reports summary with no vulnerabilities when critical devDependency and skip-dev is true", () => {
|
409 | 417 | const summary = report(
|
410 | 418 | reportNpmSkipDevelopment,
|
|
0 commit comments