theintern / intern

A next-generation code testing stack for JavaScript.
https://theintern.io/
Other
4.36k stars 310 forks source link

Cannot pin tunnel browser to SemVer version #1178

Open kgibb opened 3 years ago

kgibb commented 3 years ago

Expected behavior

Pin a particular browser version on a remote Selenium grid.

"environments": [
    {
      "browserName": "chrome",
      "browserVersion": "87.0.4280.66"
    }
]

Current behavior

Error: Invalid alias syntax "87.0.4280.66"
  at resolveVersionAlias @ src/lib/resolveEnvironments.ts:174:10
  @ src/lib/resolveEnvironments.ts:312:23
  at Array.map @ anonymous
  at resolveVersions @ src/lib/resolveEnvironments.ts:311:42
  @ src/lib/resolveEnvironments.ts:36:27
  at Array.map @ anonymous
  at Object.resolveEnvironments [as default] @ src/lib/resolveEnvironments.ts:35:48
  @ src/lib/executors/Node.ts:858:12
  @ node_modules/@theintern/common/index.js:16:7174

Setting to "87" throws an error on the grid as it is not an exact match.

Possible solution

Remove number validation if it is not necessary for other services. https://github.com/theintern/intern/blob/a3b9643d43989d586dafc264200508ab96e65dfa/packages/core/src/lib/resolveEnvironments.ts#L169

Intern: 4.8.4

jason0x43 commented 3 years ago

The validator could be updated to accept version strings (x.y.z.w) rather than only simple numbers.

kgibb commented 3 years ago

browserVersion is defined as a string identifier in the spec. Is there any value in validating the version considering the varying values supported by drivers/services? e.g. latest, latest-1, 86, 86.0b5, 87.0.4280.66, insider preview....

jason0x43 commented 3 years ago

The validation could be relaxed. The core issue is just that local selenium grids weren't considered when the resolution code was written. Cloud services were the prime driver of the version resolution code, and they all support abbreviated versions (e.g., 87 rather than 87.0.4280.66).

Regarding browserVersion being a string, I'd assume that's because standard version numbers like '87.0.4280.66' have to be represented using strings, not because versions should allow arbitrary strings. I think 'latest' and 'insider preview' are the only atypical version numbers I've seen.

kgibb commented 3 years ago

SauceLabs support a latest-n convention, n being the number of releases before the latest version.

jason0x43 commented 3 years ago

Yeah, that's where Intern's 'latest' alias support came from. Intern just lets that version style be applied to other cloud services as well. A similar thing could be done with a selenium grid since Selenium provides an endpoint to retrieve all the available browsers supported by the grid.