From 878f5a98e8335fa60974e56d67d010e1d718e243 Mon Sep 17 00:00:00 2001 From: gitphill Date: Wed, 8 Jan 2020 12:58:29 +0000 Subject: [PATCH] fix: allow tests to be run against any snyk API --- test/policy-display.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/policy-display.test.ts b/test/policy-display.test.ts index 8b1454a475..6972f9e320 100644 --- a/test/policy-display.test.ts +++ b/test/policy-display.test.ts @@ -3,6 +3,10 @@ import { test } from 'tap'; import * as fs from 'then-fs'; import { display } from '../src/lib/display-policy'; import stripAnsi from 'strip-ansi'; +import { URL } from 'url'; + +const SNYK_API = process.env.SNYK_API || 'https://snyk.io/api/v1'; +const { hostname } = new URL(SNYK_API); test('test sensibly bails if gets an old .snyk format', async (t) => { const filename = __dirname + '/fixtures/snyk-config-no-version'; @@ -21,6 +25,8 @@ test('test sensibly bails if gets an old .snyk format', async (t) => { .join('\n'); const expected = expectedFileString .trim() + // replace hostname in policy if using env var SNYK_API + .replace(/snyk\.io/g, hostname) .split('\n') .slice(3) .join('\n');