Files
baron_qa_write/tests/dependency-lock.test.js
T

18 lines
1015 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
test('dependency lock contains complete package versions for a clean CI installation', () => {
const lock = JSON.parse(readFileSync(new URL('../package-lock.json', import.meta.url), 'utf8'));
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
assert.equal(lock.lockfileVersion, 3);
assert.equal(lock.packages['node_modules/wrangler'].version, manifest.devDependencies.wrangler);
for (const [name, entry] of Object.entries(lock.packages)) {
if (!name || entry.link) continue;
assert.equal(typeof entry.version, 'string', name + ' is missing its version');
assert.match(entry.version, /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/, name + ' has an invalid version');
assert.ok(entry.resolved, name + ' is missing its package location');
assert.ok(entry.integrity, name + ' is missing its package integrity');
}
});