Repository navigation
Make the tests pass, with a key that carries the properties they read - #8
Merged
Merged
Conversation
The declarations step, tsc -p tsconfig.json, reads every @types package in node_modules, including @types/node, which jest and its packages require at any version. There is no lockfile, so yarn installs the newest, 26.6.6, which needs TypeScript 5.6. Its ffi.d.ts does not parse with the TypeScript 4.9 this package builds with, so yarn build stopped with "node_modules/@types/node/ffi.d.ts(94,21): error TS1139: Type parameter declaration expected" in every run of the tests in the workflow's history, from 3 November. The resolution holds @types/node at 22.9.3, the newest version for TypeScript 4.9.
The browser tests launch their own Chrome with puppeteer.launch, so the CI options in jest-puppeteer.config.js, which turn the sandbox off, do not reach them. On the GitHub hosted Ubuntu runner Chrome stopped with "No usable sandbox!", so both tests failed before reaching the page. They now launch it with the same arguments when CI is set.
The cloud now answers "The resource key '...' could not be found. Check that you copied it correctly, or create a new key at ...", where the test expected "The Resource Key '...' was not found. See ... for more information.". The test now matches the start of the message, which names the key, and the mock gives that start as its error.
The happy path tests read PlatformName and PlatformVersion, and the key in the USER_KEY_VALID secret is a free CloudV5Basic key, so the cloud answers each with "PlatformVersion is a paid feature" and a null value, and the tests fail on null.toLowerCase(). The organisation's _51DEGREES_RESOURCE_KEY_BESPOKE key carries every property the README recommends, and the cloud answers the happy path request with macOS 12.2.1. The test and publish workflows now use it as USER_KEY_VALID.
The happy injection test caught every error in its body, including a failed expectation, logged it and closed the browser, so it passed whatever the page showed. It now only closes the browser, in finally, so a failed expectation fails the test.
The two pages the browser tests load asked the cloud with a key written into each page, a free key without PlatformName or PlatformVersion, so both tests read null. server.js now puts the key from USER_KEY_VALID, which the workflows set and .env can give locally, in place of __USER_KEY_VALID__ in each page as it serves it, so the browser tests ask with the same key as the Node tests and no key is kept in the repository.
The injection test read the page's result two seconds after the page loaded, but the result is written only once the cloud's script has done its own requests, so the test read an empty element and failed to parse it. It now waits for the page to write the result, for up to 20 seconds. The page writes an error it meets in place of the result, so a failure says why.
The test key carries the location product, and the cloud's script then asks the browser for its location and waits for the answer before it resolves the result. Headless Chrome leaves the request unanswered, so the result never came. A check in headless Chrome showed the page resolve within a second with the location allowed, with each of the organisation's paid keys, and never without it. The test now allows the page a location, as a visitor would.
jwrosewell
marked this pull request as ready for review
November 6, 2026 07:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
ua-parser-js-run-testworkflow (.github/workflows/run-test.yml) has failed on every run in its history, from 3 November, including the pushes torcandmainon 4 November (run 41786620555 onmain). There were six faults, each hidden behind the one before.yarn buildstopped in the declarations step, withnode_modules/@types/node/ffi.d.ts(94,21): error TS1139: Type parameter declaration expectedand many like it.tsc -p tsconfig.jsonreads every@typespackage innode_modules, and@types/nodecomes in through jest and its packages at any version. There is no lockfile, so yarn installs the newest, 26.6.6, which needs TypeScript 5.6, while this package builds with TypeScript 4.9.puppeteer.launchthemselves, so the CI options injest-puppeteer.config.js, which turn the sandbox off, never reach them, and on the GitHub hosted Ubuntu runner Chrome stopped with "No usable sandbox!".USER_KEY_VALIDsecret, and the one written into the two browser test pages, are free CloudV5Basic keys. The cloud answers each property withnulland "PlatformVersion is a paid feature", and the tests failed onnull.toLowerCase().Change
package.jsongains a yarnresolutionsentry that holds@types/nodeat 22.9.3, the newest version for TypeScript 4.9 according to itstypeScriptVersionon the npm registry.--no-sandboxand--disable-setuid-sandboxwhenCIis set, the argumentsjest-puppeteer.config.jsalready uses.src/__mocks__/errors.tsgives the start of the cloud's current message, which names the key, and the node integration test matches that start rather than the whole message, which goes on to say where to create a key.USER_KEY_VALIDfrom the organisation's_51DEGREES_RESOURCE_KEY_BESPOKEsecret, a CloudV5Bespoke key that carries every property the README recommends. The two browser test pages hold the placeholder__USER_KEY_VALID__, whichserver.jsreplaces with that key as it serves them, loading.envas the tests already do, so no key is kept in the repository.finally, so a failed expectation fails it.Checks
nulland "PlatformVersion is a paid feature" for the repository's key, and with macOS 12.2.1 for_51DEGREES_RESOURCE_KEY_BESPOKE. Each key's accessible properties were read without printing the key.Not changed
A page that uses UAParser without a header map, with a key that carries the location product, waits for its visitor to answer the browser's location prompt before UAParser resolves. That is how the cloud's script behaves, and this change only lets the test answer the prompt.
Release note
The tests run and pass again, with a key that carries the properties they check.