Skip to content

vitest with happy-dom: window.CSS.supports is undefined #4576

@dr2009

Description

@dr2009

Describe the bug

// environment: 'happy-dom'
console.log(CSS); // { escape: [Function: cssEscape] }
expect(CSS.escape).toBeDefined(); // ok
expect(CSS.supports).toBeDefined(); // not ok

becuase happy-dom depends css.escape, it will change global.CSS to { escape: cssEscape } when import it

https://github.com/mathiasbynens/CSS.escape/blob/master/css.escape.js#L97-L101

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-12tbkc?file=vite.config.ts,test%2Fsuite.test.ts,test%2Fbasic.test.ts&initialPath=__vitest__/

System Info

System:
    OS: macOS 13.2
    CPU: (8) arm64 Apple M1
    Memory: 155.31 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/Library/Caches/fnm_multishells/15709_1700617114296/bin/node
    npm: 10.1.0 - ~/Library/Caches/fnm_multishells/15709_1700617114296/bin/npm
    pnpm: 8.10.5 - ~/Library/Caches/fnm_multishells/15709_1700617114296/bin/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.159
    Edge: 116.0.1938.76
    Safari: 16.3
    Safari Technology Preview: 16.4
  npmPackages:
    @vitest/coverage-v8: 1.0.0-beta.4 => 1.0.0-beta.4 
    vitest: 1.0.0-beta.4 => 1.0.0-beta.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions