Skip to content

Commit

Permalink
Fix engines.test.js for multiple potential versions (#197)
Browse files Browse the repository at this point in the history
`npm view` can return an array or a single string depending on published versions.

See below:

```console
$ npm view --json stylelint@^15.9.0 engines.node
[
  "^14.13.1 || >=16.0.0",
  "^14.13.1 || >=16.0.0"
]
```

```console
$ npm view --json stylelint@^15.10.0 engines.node
"^14.13.1 || >=16.0.0"
```
  • Loading branch information
ybiquitous committed Jul 5, 2023
1 parent 26b84e0 commit 6e5406e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion __tests__/engines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ describe('engines.node', () => {
]).toString(),
);

expect(nodeVersion).toEqual(pkg.engines.node);
// `^x.y.z` range can return multiple versions.
const nodeVersions = Array.isArray(nodeVersion) ? [...new Set(nodeVersion)] : [nodeVersion];

expect(nodeVersions).toHaveLength(1);
expect(nodeVersions).toContain(pkg.engines.node);
});
});

0 comments on commit 6e5406e

Please sign in to comment.