Troubleshooting and FAQ#
Visual tests and Vitest browser mode#
Screenshot tests run with Vitest browser mode and use Playwright as the browser provider under the hood. The helper in core/vitest-screenshots/ drives a single Firefox page per worker against the running portal on http://localhost:8000. The screenshot config sets fileParallelism: true, so test files run in parallel across workers while tests inside a file run sequentially on the same page.
Installing screenshot browser#
For running screenshot tests (visual tests), a headless Firefox browser is needed.
In normal circumstances, the browser will be installed automatically via yarn install – but to either upgrade to a newer version, or to wipe out existing versions and run the install manually, you can run these commands, depending on your needs:
yarn workspace @dnb/eufemia playwright uninstall --allyarn workspace @dnb/eufemia add -D @playwright/testyarn workspace @dnb/eufemia playwright install firefoxyarn workspace dnb-design-system-portal playwright uninstall --allyarn workspace dnb-design-system-portal add -D @playwright/testyarn workspace dnb-design-system-portal playwright install firefox
Alternative install: behind a corporate proxy#
A proxy that re-signs HTTPS traffic can make the install fail with
Error: unable to get local issuer certificate. Point Node.js to your organization's root
certificate (a PEM file from your IT department) and run the install again:
NODE_EXTRA_CA_CERTS=/path/to/root-ca.pem yarn workspace @dnb/eufemia playwright install firefox
Alternative install: manually#
Or, in the very worst case, you can manually download the zip file that yarn workspace @dnb/eufemia playwright install firefox attempts to download, and extract the file
("Nightly" for Firefox) to the folder indicated when yarn test:screenshots fails.
How can I run all screenshot tests in CI?#
By default, CI runs only affected screenshot tests based on changed files and reverse dependencies. If a global style change is detected, all screenshot tests are run.
To force all screenshot tests, include --run-all in your commit message:
git commit -m "feat: implement new feature --run-all"
CI does not stop on the first failure, so a run reports all visual differences at once.
What does build:mini do?#
When running build:mini scripts, the build will be faster and the output will be smaller. It's used for the CI/CD pipeline to build the package for the documentation preview.
Dependency issues#
Yarn patches#
- We patch
eslint-plugin-import-x4.17.1 so that it works with minimatch 11. The rootresolutionsmove minimatch 9 and 10 to 11 for a security fix, and minimatch 11 no longer exportsmakeRe, which the plugin'sno-internal-modulesrule imports. Without the patch, ESLint fails to start withdoes not provide an export named 'makeRe'. The patch is a port of un-ts/eslint-plugin-import-x#570. It lives in.yarn/patches/and is applied by theeslint-plugin-import-x@npm:4.17.1entry in the rootresolutions. Remove the patch and that entry when a plugin release includes the fix. If you change the plugin version,yarn lint:resolutionsfails until you update or remove the entry.
Babel#
- Due to this bug: https://github.com/babel/babel/issues/11394 we add
.png,.snapso they do not get copied:--extensions '.js,.ts,.tsx,.png,.snap'