Skip to content

bug: In spec tests : ReferenceError: ShadowRoot is not defined #3260

@ryuran

Description

@ryuran

Prerequisites

Stencil Version

2.14.0

Current Behavior

this.el.getRootNode() instanceof ShadowRoot
I try to know if my custom component is in a shadowDOM.
It works well but not in specs test.
I have this error ReferenceError: ShadowRoot is not defined

Expected Behavior

No error in test when we use ShadowRoot

Steps to Reproduce

Try to test if the host element is in a shadowDOM context
this.el.getRootNode() instanceof ShadowRoot

Then run unit tests.

Code Reproduction URL

https://github.com/ryuran/stencil-bugs

Additional Information

  • npm i
  • npm test

Workaround

Mock:

global.DocumentFragment = class DocumentFragment extends Node {};
global.ShadowRoot = class ShadowRoot extends DocumentFragment {};

Metadata

Metadata

Labels

Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions