forked from alphagov/govuk-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-lock.json.unit.test.mjs
31 lines (27 loc) · 1.08 KB
/
package-lock.json.unit.test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
describe('package-lock.json', () => {
/** @type {import('./package-lock.json')} */
let packageLockJson
beforeAll(async () => {
packageLockJson = await import('./package-lock.json')
})
describe('Dependabot updates', () => {
/**
* When this check fails, the incorrect `package-lock.json` can be repaired
* by checking out the Dependabot branch and running `npm install` to remove
* the hoisted dependency
*
* {@link https://govuk-design-system-team-docs.netlify.app/how-we-work/version-control/pull-requests#reviewing-a-pr-from-dependabot}
*/
it("should not hoist 'optionalDependencies' to 'dependencies'", () => {
const { dependencies, optionalDependencies } =
packageLockJson.packages['']
// List package names for comparison
const packageNames = Object.keys(dependencies ?? {})
const packageNamesOptional = Object.keys(optionalDependencies ?? {})
// Check no optional dependencies are hoisted
for (const name of packageNamesOptional) {
expect(packageNames).not.toContain(name)
}
})
})
})