Skip to content

test(styles): add jsdom and fix EdsTokens global style test - #3491

Closed
chdefrene wants to merge 1 commit into
mainfrom
chdefrene-styles-jsdom
Closed

chdefrene wants to merge 1 commit into
mainfrom
chdefrene-styles-jsdom

Conversation

@chdefrene

Copy link
Copy Markdown
Member

Component Development

Type

  • Feature
  • Fix
  • Hotfix (should release ASAP)
  • Maintenance (deps only)

Reference to assignment

Description of assignment

Why: The @equinor/fusion-react-styles test suite could not run on main: vitest.config.ts uses the jsdom environment, but jsdom was not installed (MISSING DEPENDENCY Cannot find dependency 'jsdom'). Once installed, EdsTokens - CSS Variables Rendering failed because no <style> tags were injected.

Description of Proposed Changes

What:

  • Add jsdom as a devDependency of packages/styles (via bun add -d jsdom; bun.lock updated by bun).
  • Alias styled-components to its browser ESM build in packages/styles/vitest.config.ts. Vitest resolves the Node build (module field), which only renders global styles during SSR; client-side injection only exists in the browser-field build, so createGlobalStyle never reached the jsdom DOM.
  • Test/dev-only: no runtime or published output changes, so no changeset.

Validation:

  • bunx vitest run (packages/styles): 56 passed / 0 failed (before: suite could not start; with jsdom only: 55 passed / 1 failed)
  • bunx biome check packages/styles/vitest.config.ts packages/styles/package.json: no findings

Checklist

Create User Story(DevOps) or Issue(Github)

  • Describe functional requirements
  • Design plan/suggestion (e.g. images, link to eds design or relevant figma links, mention of eds tokens to use)
  • Communication with UX (evaluate if needed)

Development

  • Describe the component
  • Code funtional requirements
  • Create stories
  • Create snapshots (evaluate if needed)
  • Remove unused imports and commented code
  • Lint code with Biome (and follow best practises for code quality

Create Pull Request

  • Assign relevant reviewers in Github and Cromatic
  • Inform colleagues of pending reviews. We use Teams for this purpose, under fusion-frontend team please tag involved reviewers in the Code review channel

Review of Pull Request

  • Follow up on comments from code review and implement necessary changes (evaluate if needed)
  • Review approved in github (and chromatic)

Publish Code

  • Increment version number
  • Merge PR
  • Consider letting fusion developers know this this shiny new thing exists

The styles test suite uses the jsdom environment, but jsdom was not a
dependency, so no tests could run. Add it as a devDependency.

The EdsTokens test failed because vitest resolves styled-components'
Node build (via `module`), which only emits global styles during SSR.
Alias styled-components to its browser build in the vitest config so
client-side style injection reaches the jsdom DOM.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 28, 2026 09:32
@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f4fd74e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The missing jsdom dependency and browser-oriented styled-components alias address the identified Vitest setup issues without changing published runtime output.

No open issues 🎉

What changed in this PR

This maintenance pull request restores the packages/styles Vitest suite by adding the missing jsdom dependency and resolving styled-components to its browser build so global styles render correctly in jsdom.

Changes:

  • Add jsdom as a development dependency.
  • Alias styled-components to its browser ESM build for Vitest.
  • Update bun.lock with the dependency graph.
  • No published runtime output changes.
File Description
packages/​styles/​vitest.config.ts Configures the browser-oriented styled-components build for jsdom tests.
packages/​styles/​package.json Adds jsdom as a development dependency.
bun.lock Records the new dependency and its transitive packages.

Review effort: Lite

@chdefrene chdefrene closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants