yarn-plugin: add failing test for snyk lockfile parsing issue

A recent change reintroduced the issue previously
fixed by #27727. To ensure this doesn't regress
again, I'm introducing a test that specifically
checks that lockfile parsing works as expected.

Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
MT Lewis
2025-01-07 18:07:57 +00:00
committed by Vincenzo Scamporlino
parent ed39f53e0d
commit 3ebbc6b48f
3 changed files with 560 additions and 24 deletions
+1
View File
@@ -43,6 +43,7 @@
"@yarnpkg/builder": "^4.0.0",
"fs-extra": "^11.2.0",
"nodemon": "^3.0.1",
"snyk-nodejs-lockfile-parser": "^1.58.14",
"yaml": "^2.0.0"
}
}
+18
View File
@@ -18,6 +18,7 @@ import { join as joinPath } from 'path';
import { spawn, SpawnOptionsWithoutStdio } from 'child_process';
import fs from 'fs-extra';
import yaml from 'yaml';
import { buildDepTreeFromFiles } from 'snyk-nodejs-lockfile-parser';
import { findPaths } from '@backstage/cli-common';
import { createMockDirectory } from '@backstage/backend-test-utils';
@@ -301,6 +302,23 @@ describe('Backstage yarn plugin', () => {
});
},
);
it('successfully parses the lockfile with snyk-nodejs-lockfile-parser', async () => {
await expect(
buildDepTreeFromFiles(
mockDir.path,
'packages/b/package.json',
'yarn.lock',
),
).resolves.toEqual(
expect.objectContaining({
dependencies: expect.objectContaining({
'@backstage/cli-common': expect.anything(),
'@backstage/config': expect.anything(),
}),
}),
);
});
});
});
});