shadow-dom-testing-library
Advanced tools
Comparing version 1.8.0 to 1.9.0
var xe=Object.defineProperty;var ge=(e,o)=>{for(var n in o)xe(e,n,{get:o[n],enumerable:!0})};import{queries as mt,within as wt}from"@testing-library/dom";var E={};ge(E,{findAllByShadowAltText:()=>v,findAllByShadowDisplayValue:()=>W,findAllByShadowLabelText:()=>H,findAllByShadowPlaceholderText:()=>V,findAllByShadowRole:()=>L,findAllByShadowTestId:()=>se,findAllByShadowText:()=>j,findAllByShadowTitle:()=>ae,findByShadowAltText:()=>ee,findByShadowDisplayValue:()=>Y,findByShadowLabelText:()=>I,findByShadowPlaceholderText:()=>_,findByShadowRole:()=>q,findByShadowTestId:()=>ce,findByShadowText:()=>k,findByShadowTitle:()=>le,getAllByShadowAltText:()=>K,getAllByShadowDisplayValue:()=>X,getAllByShadowLabelText:()=>b,getAllByShadowPlaceholderText:()=>N,getAllByShadowRole:()=>P,getAllByShadowTestId:()=>de,getAllByShadowText:()=>$,getAllByShadowTitle:()=>oe,getByShadowAltText:()=>Z,getByShadowDisplayValue:()=>z,getByShadowLabelText:()=>D,getByShadowPlaceholderText:()=>C,getByShadowRole:()=>R,getByShadowTestId:()=>he,getByShadowText:()=>U,getByShadowTitle:()=>ne,queryAllByShadowAltText:()=>M,queryAllByShadowDisplayValue:()=>p,queryAllByShadowLabelText:()=>y,queryAllByShadowPlaceholderText:()=>T,queryAllByShadowRole:()=>S,queryAllByShadowTestId:()=>A,queryAllByShadowText:()=>f,queryAllByShadowTitle:()=>B,queryByShadowAltText:()=>J,queryByShadowDisplayValue:()=>G,queryByShadowLabelText:()=>Q,queryByShadowPlaceholderText:()=>O,queryByShadowRole:()=>g,queryByShadowTestId:()=>re,queryByShadowText:()=>F,queryByShadowTitle:()=>te});import{buildQueries as c,queryAllByRole as Re,queryAllByLabelText as Le,queryAllByPlaceholderText as qe,queryAllByText as Qe,queryAllByDisplayValue as be,queryAllByAltText as De,queryAllByTitle as He,queryAllByTestId as Ie}from"@testing-library/dom";function Pe(e,o,n={shallow:!1}){let t=Se(e,o,n);return Array.isArray(t)&&t.length>0?t[0]:null}function Se(e,o,n={shallow:!1}){let a=h(e,n).map(l=>Array.from(l.querySelectorAll(o))).flat(1/0);return[...new Set(a)]}function h(e,o={shallow:!1}){return ye(e,"*",o)}function ye(e,o,n={shallow:!1},t=[],a=[]){return e instanceof Document&&(e=document.documentElement),t=[e],a.push(e),e instanceof HTMLElement&&e.shadowRoot!=null&&e.shadowRoot.mode!=="closed"&&(a.push(e.shadowRoot),t.push(e.shadowRoot)),t.forEach(l=>{l.querySelectorAll(o).forEach(r=>{if(r.shadowRoot==null||r.shadowRoot.mode==="closed"){a.push(r);return}if(a.push(r.shadowRoot),n.shallow===!0){r.shadowRoot.querySelectorAll(o).forEach(d=>{a.push(d)});return}r.shadowRoot.querySelectorAll(o).forEach(d=>{a.push(d),t.push(d)}),ye(r.shadowRoot,o,n,t,a)})}),[...new Set(a)]}function u(e){return e.map(o=>(...n)=>{let[t,a,l,...r]=n;return l==null&&(l={}),l.suggest=!1,o(t,a,l,...r)})}function S(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>Re(a,n,t)).flat(1/0))]}var Oe=(e,o)=>`Found multiple elements with the role of: ${o}`,Ne=(e,o)=>`Unable to find an element with the role of: ${o}`,[g,P,R,L,q]=u(c(S,Oe,Ne));function y(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>Le(a,n,t)).flat(1/0))]}var Ce=(e,o)=>`Found multiple elements with the label text of: ${o}`,Ve=(e,o)=>`Unable to find an element with the label text of: ${o}`,[Q,b,D,H,I]=u(c(y,Ce,Ve));function T(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>qe(a,n,t)).flat(1/0))]}var _e=(e,o)=>`Found multiple elements with the placeholder text of: ${o}`,Fe=(e,o)=>`Unable to find an element with the placeholder text of: ${o}`,[O,N,C,V,_]=u(c(T,_e,Fe));function f(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>Qe(a,n,t)).flat(1/0))]}var $e=(e,o)=>`Found multiple elements with the text of: ${o}`,Ue=(e,o)=>`Unable to find an element with the text of: ${o}`,[F,$,U,j,k]=u(c(f,$e,Ue));function p(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>be(a,n,t)).flat(1/0))]}var je=(e,o)=>`Found multiple elements with the display value of: ${o}`,ke=(e,o)=>`Unable to find an element with the display value of: ${o}`,[G,X,z,W,Y]=u(c(p,je,ke));function M(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>De(a,n,t)).flat(1/0))]}var Ge=(e,o)=>`Found multiple elements with the alt text of: ${o}`,Xe=(e,o)=>`Unable to find an element with the alt text of: ${o}`,[J,K,Z,v,ee]=u(c(M,Ge,Xe));function B(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>He(a,n,t)).flat(1/0))]}var ze=(e,o)=>`Found multiple elements with the title of: ${o}`,We=(e,o)=>`Unable to find an element with the title of: ${o}`,[te,oe,ne,ae,le]=u(c(B,ze,We));function A(...e){let[o,n,t]=e;return t==null&&(t={}),t.suggest=!1,[...new Set(h(o,t).map(a=>Ie(a,n,t)).flat(1/0))]}var Ye=(e,o)=>`Found multiple elements with the test id of: ${o}`,Je=(e,o)=>`Unable to find an element with the test id of: ${o}`,[re,de,he,se,ce]=u(c(A,Ye,Je));import{logDOM as ct}from"@testing-library/dom";import{prettyDOM as Ke,getConfig as Ze}from"@testing-library/dom";function ve(...e){let[o,n,t]=e,a=me((t==null?void 0:t.filterNode)||ue);return t==null&&(t={}),t.plugins==null&&(t.plugins=[]),t.plugins.push(a),Ke(o,n,{...t,plugins:[a]})}function fe(e){return e.replace(/</g,"<").replace(/>/g,">")}function ue(e){return e.nodeType!==ie&&(e.nodeType!==Me||!e.matches(Ze().defaultIgnore))}var et=(e,o,n,t,a,l,r)=>{let d=t+n.indent,s=n.colors;return e.map(i=>{let w=o[i],m=r(w,n,d,a,l);return typeof w!="string"&&(m.indexOf(` | ||
`)!==-1&&(m=n.spacingOuter+d+m+n.spacingOuter+t),m="{"+m+"}"),n.spacingInner+t+s.prop.open+i+s.prop.close+"="+s.value.open+m+s.value.close}).join("")},tt=3,ot=(e,o,n,t,a,l)=>e.map(r=>{let d=typeof r=="string"?pe(r,o):l(r,o,n,t,a);return d===""&&typeof r=="object"&&r!==null&&r.nodeType!==tt?"":o.spacingOuter+n+d}).join(""),pe=(e,o)=>{let n=o.colors.content;return n.open+fe(e)+n.close},nt=(e,o)=>{let n=o.colors.comment;return n.open+"<!--"+fe(e)+"-->"+n.close},at=(e,o,n,t,a)=>{let l=t.colors.tag;return l.open+"<"+e+(o&&l.close+o+t.spacingOuter+a+l.open)+(n?">"+l.close+n+t.spacingOuter+a+l.open+"</"+e:(o&&!t.min?"":" ")+"/")+">"+l.close},lt=(e,o)=>{let n=o.colors.tag;return n.open+"<"+e+n.close+" \u2026"+n.open+" />"+n.close},Me=1,Be=3,ie=8,Ae=11,rt=/^((HTML|SVG)\w*)?Element$/,dt=e=>{var l;let o=((l=e==null?void 0:e.constructor)==null?void 0:l.name)||"",{nodeType:n,tagName:t}=e,a=typeof t=="string"&&t.includes("-")||typeof e.hasAttribute=="function"&&e.hasAttribute("is")||e instanceof HTMLElement;return n===Me&&(rt.test(o)||a)||n===Be&&o==="Text"||n===ie&&o==="Comment"||n===Ae};function ht(e){return e.nodeType===Be}function st(e){return e.nodeType===ie}function Te(e){return e.nodeType===Ae}function me(e){function o(n){let t=Array.prototype.slice.call(n.childNodes||n.children);return"shadowRoot"in n&&n.shadowRoot!=null&&n.shadowRoot.mode!=="closed"&&t.unshift(n.shadowRoot),t.filter(e)}return{test:n=>(n==null?void 0:n.constructor)&&dt(n),serialize:(n,t,a,l,r,d)=>{if(ht(n))return pe(n.data,t);if(st(n))return nt(n.data,t);let s="DocumentFragment";return"tagName"in n&&n.tagName?s=n.tagName.toLowerCase():n instanceof ShadowRoot&&(s="ShadowRoot"),++l>t.maxDepth?lt(s,t):at(s,et(Te(n)?[]:Array.from(n.attributes).map(i=>i.name).sort(),Te(n)?{}:Array.from(n.attributes).reduce((i,w)=>(i[w.name]=w.value,i),{}),t,a+t.indent,l,r,d),ot(o(n),t,a+t.indent,l,r,d),t,a)}}}function x(...e){let[o,n,t]=e,a=me((t==null?void 0:t.filterNode)||ue);t==null&&(t={}),t.plugins==null&&(t.plugins=[]),t.plugins.push(a),ct(o,n,t)}function we(...e){let[o,n,t]=e;Array.isArray(o)?o.forEach(a=>x(a,n,t)):x(o,n,t)}import{screen as ut}from"@testing-library/dom";var it={...ut,debug:we,queryAllByShadowRole:(...e)=>S(document.documentElement,e[0],e[1]),queryByShadowRole:(...e)=>g(document.documentElement,e[0],e[1]),getAllByShadowRole:(...e)=>P(document.documentElement,e[0],e[1]),getByShadowRole:(...e)=>R(document.documentElement,e[0],e[1]),findAllByShadowRole:(...e)=>L(document.documentElement,e[0],e[1],e[2]),findByShadowRole:(...e)=>q(document.documentElement,e[0],e[1],e[2]),queryAllByShadowLabelText:(...e)=>y(document.documentElement,e[0],e[1]),queryByShadowLabelText:(...e)=>Q(document.documentElement,e[0],e[1]),getAllByShadowLabelText:(...e)=>b(document.documentElement,e[0],e[1]),getByShadowLabelText:(...e)=>D(document.documentElement,e[0],e[1]),findAllByShadowLabelText:(...e)=>H(document.documentElement,e[0],e[1],e[2]),findByShadowLabelText:(...e)=>I(document.documentElement,e[0],e[1],e[2]),queryAllByShadowPlaceholderText:(...e)=>T(document.documentElement,e[0],e[1]),queryByShadowPlaceholderText:(...e)=>O(document.documentElement,e[0],e[1]),getAllByShadowPlaceholderText:(...e)=>N(document.documentElement,e[0],e[1]),getByShadowPlaceholderText:(...e)=>C(document.documentElement,e[0],e[1]),findAllByShadowPlaceholderText:(...e)=>V(document.documentElement,e[0],e[1],e[2]),findByShadowPlaceholderText:(...e)=>_(document.documentElement,e[0],e[1],e[2]),queryAllByShadowText:(...e)=>f(document.documentElement,e[0],e[1]),queryByShadowText:(...e)=>F(document.documentElement,e[0],e[1]),getAllByShadowText:(...e)=>$(document.documentElement,e[0],e[1]),getByShadowText:(...e)=>U(document.documentElement,e[0],e[1]),findAllByShadowText:(...e)=>j(document.documentElement,e[0],e[1],e[2]),findByShadowText:(...e)=>k(document.documentElement,e[0],e[1],e[2]),queryAllByShadowDisplayValue:(...e)=>p(document.documentElement,e[0],e[1]),queryByShadowDisplayValue:(...e)=>G(document.documentElement,e[0],e[1]),getAllByShadowDisplayValue:(...e)=>X(document.documentElement,e[0],e[1]),getByShadowDisplayValue:(...e)=>z(document.documentElement,e[0],e[1]),findAllByShadowDisplayValue:(...e)=>W(document.documentElement,e[0],e[1],e[2]),findByShadowDisplayValue:(...e)=>Y(document.documentElement,e[0],e[1],e[2]),queryAllByShadowAltText:(...e)=>M(document.documentElement,e[0],e[1]),queryByShadowAltText:(...e)=>J(document.documentElement,e[0],e[1]),getAllByShadowAltText:(...e)=>K(document.documentElement,e[0],e[1]),getByShadowAltText:(...e)=>Z(document.documentElement,e[0],e[1]),findAllByShadowAltText:(...e)=>v(document.documentElement,e[0],e[1],e[2]),findByShadowAltText:(...e)=>ee(document.documentElement,e[0],e[1],e[2]),queryAllByShadowTitle:(...e)=>B(document.documentElement,e[0],e[1]),queryByShadowTitle:(...e)=>te(document.documentElement,e[0],e[1]),getAllByShadowTitle:(...e)=>oe(document.documentElement,e[0],e[1]),getByShadowTitle:(...e)=>ne(document.documentElement,e[0],e[1]),findAllByShadowTitle:(...e)=>ae(document.documentElement,e[0],e[1],e[2]),findByShadowTitle:(...e)=>le(document.documentElement,e[0],e[1],e[2]),queryAllByShadowTestId:(...e)=>A(document.documentElement,e[0],e[1]),queryByShadowTestId:(...e)=>re(document.documentElement,e[0],e[1]),getAllByShadowTestId:(...e)=>de(document.documentElement,e[0],e[1]),getByShadowTestId:(...e)=>he(document.documentElement,e[0],e[1]),findAllByShadowTestId:(...e)=>se(document.documentElement,e[0],e[1],e[2]),findByShadowTestId:(...e)=>ce(document.documentElement,e[0],e[1],e[2])};function Ee(){if(typeof ShadowRoot>"u")throw"Your environment does not support shadow roots.";ShadowRoot.prototype.matches==null&&Object.defineProperties(ShadowRoot.prototype,{matches:{get(){return function(e){return e.trim()==="*"?!0:this.querySelector(e)!=null}}}}),ShadowRoot.prototype.outerHTML==null&&Object.defineProperties(ShadowRoot.prototype,{outerHTML:{get(){return this.innerHTML}}})}Ee();var St={...mt,...E};function _t(e){return wt(e,St)}export{we as debug,Pe as deepQuerySelector,Se as deepQuerySelectorAll,v as findAllByShadowAltText,W as findAllByShadowDisplayValue,H as findAllByShadowLabelText,V as findAllByShadowPlaceholderText,L as findAllByShadowRole,se as findAllByShadowTestId,j as findAllByShadowText,ae as findAllByShadowTitle,ee as findByShadowAltText,Y as findByShadowDisplayValue,I as findByShadowLabelText,_ as findByShadowPlaceholderText,q as findByShadowRole,ce as findByShadowTestId,k as findByShadowText,le as findByShadowTitle,K as getAllByShadowAltText,X as getAllByShadowDisplayValue,b as getAllByShadowLabelText,N as getAllByShadowPlaceholderText,P as getAllByShadowRole,de as getAllByShadowTestId,$ as getAllByShadowText,oe as getAllByShadowTitle,h as getAllElementsAndShadowRoots,Z as getByShadowAltText,z as getByShadowDisplayValue,D as getByShadowLabelText,C as getByShadowPlaceholderText,R as getByShadowRole,he as getByShadowTestId,U as getByShadowText,ne as getByShadowTitle,x as logShadowDOM,ve as prettyShadowDOM,M as queryAllByShadowAltText,p as queryAllByShadowDisplayValue,y as queryAllByShadowLabelText,T as queryAllByShadowPlaceholderText,S as queryAllByShadowRole,A as queryAllByShadowTestId,f as queryAllByShadowText,B as queryAllByShadowTitle,J as queryByShadowAltText,G as queryByShadowDisplayValue,Q as queryByShadowLabelText,O as queryByShadowPlaceholderText,g as queryByShadowRole,re as queryByShadowTestId,F as queryByShadowText,te as queryByShadowTitle,it as screen,_t as within}; | ||
`)!==-1&&(m=n.spacingOuter+d+m+n.spacingOuter+t),m="{"+m+"}"),n.spacingInner+t+s.prop.open+i+s.prop.close+"="+s.value.open+m+s.value.close}).join("")},tt=3,ot=(e,o,n,t,a,l)=>e.map(r=>{let d=typeof r=="string"?pe(r,o):l(r,o,n,t,a);return d===""&&typeof r=="object"&&r!==null&&r.nodeType!==tt?"":o.spacingOuter+n+d}).join(""),pe=(e,o)=>{let n=o.colors.content;return n.open+fe(e)+n.close},nt=(e,o)=>{let n=o.colors.comment;return n.open+"<!--"+fe(e)+"-->"+n.close},at=(e,o,n,t,a)=>{let l=t.colors.tag;return l.open+"<"+e+(o&&l.close+o+t.spacingOuter+a+l.open)+(n?">"+l.close+n+t.spacingOuter+a+l.open+"</"+e:(o&&!t.min?"":" ")+"/")+">"+l.close},lt=(e,o)=>{let n=o.colors.tag;return n.open+"<"+e+n.close+" \u2026"+n.open+" />"+n.close},Me=1,Be=3,ie=8,Ae=11,rt=/^((HTML|SVG)\w*)?Element$/,dt=e=>{var l;let o=((l=e==null?void 0:e.constructor)==null?void 0:l.name)||"",{nodeType:n,tagName:t}=e,a=typeof t=="string"&&t.includes("-")||typeof e.hasAttribute=="function"&&e.hasAttribute("is")||e instanceof HTMLElement;return n===Me&&(rt.test(o)||a)||n===Be&&o==="Text"||n===ie&&o==="Comment"||n===Ae};function ht(e){return e.nodeType===Be}function st(e){return e.nodeType===ie}function Te(e){return e.nodeType===Ae}function me(e){function o(n){let t=Array.prototype.slice.call(n.childNodes||n.children);return"shadowRoot"in n&&n.shadowRoot!=null&&n.shadowRoot.mode!=="closed"&&t.unshift(n.shadowRoot),t.filter(e)}return{test:n=>(n==null?void 0:n.constructor)&&dt(n),serialize:(n,t,a,l,r,d)=>{if(ht(n))return pe(n.data,t);if(st(n))return nt(n.data,t);let s="DocumentFragment";return"tagName"in n&&n.tagName?s=n.tagName.toLowerCase():n instanceof ShadowRoot&&(s="ShadowRoot"),++l>t.maxDepth?lt(s,t):at(s,et(Te(n)?[]:Array.from(n.attributes).map(i=>i.name).sort(),Te(n)?{}:Array.from(n.attributes).reduce((i,w)=>(i[w.name]=w.value,i),{}),t,a+t.indent,l,r,d),ot(o(n),t,a+t.indent,l,r,d),t,a)}}}function x(...e){let[o,n,t]=e,a=me((t==null?void 0:t.filterNode)||ue);t==null&&(t={}),t.plugins==null&&(t.plugins=[]),t.plugins.push(a),ct(o,n,t)}function we(...e){let[o,n,t]=e;Array.isArray(o)?o.forEach(a=>x(a,n,t)):x(o,n,t)}import{screen as ut}from"@testing-library/dom";var it={...ut,debug:we,queryAllByShadowRole:(...e)=>S(document.documentElement,e[0],e[1]),queryByShadowRole:(...e)=>g(document.documentElement,e[0],e[1]),getAllByShadowRole:(...e)=>P(document.documentElement,e[0],e[1]),getByShadowRole:(...e)=>R(document.documentElement,e[0],e[1]),findAllByShadowRole:(...e)=>L(document.documentElement,e[0],e[1],e[2]),findByShadowRole:(...e)=>q(document.documentElement,e[0],e[1],e[2]),queryAllByShadowLabelText:(...e)=>y(document.documentElement,e[0],e[1]),queryByShadowLabelText:(...e)=>Q(document.documentElement,e[0],e[1]),getAllByShadowLabelText:(...e)=>b(document.documentElement,e[0],e[1]),getByShadowLabelText:(...e)=>D(document.documentElement,e[0],e[1]),findAllByShadowLabelText:(...e)=>H(document.documentElement,e[0],e[1],e[2]),findByShadowLabelText:(...e)=>I(document.documentElement,e[0],e[1],e[2]),queryAllByShadowPlaceholderText:(...e)=>T(document.documentElement,e[0],e[1]),queryByShadowPlaceholderText:(...e)=>O(document.documentElement,e[0],e[1]),getAllByShadowPlaceholderText:(...e)=>N(document.documentElement,e[0],e[1]),getByShadowPlaceholderText:(...e)=>C(document.documentElement,e[0],e[1]),findAllByShadowPlaceholderText:(...e)=>V(document.documentElement,e[0],e[1],e[2]),findByShadowPlaceholderText:(...e)=>_(document.documentElement,e[0],e[1],e[2]),queryAllByShadowText:(...e)=>f(document.documentElement,e[0],e[1]),queryByShadowText:(...e)=>F(document.documentElement,e[0],e[1]),getAllByShadowText:(...e)=>$(document.documentElement,e[0],e[1]),getByShadowText:(...e)=>U(document.documentElement,e[0],e[1]),findAllByShadowText:(...e)=>j(document.documentElement,e[0],e[1],e[2]),findByShadowText:(...e)=>k(document.documentElement,e[0],e[1],e[2]),queryAllByShadowDisplayValue:(...e)=>p(document.documentElement,e[0],e[1]),queryByShadowDisplayValue:(...e)=>G(document.documentElement,e[0],e[1]),getAllByShadowDisplayValue:(...e)=>X(document.documentElement,e[0],e[1]),getByShadowDisplayValue:(...e)=>z(document.documentElement,e[0],e[1]),findAllByShadowDisplayValue:(...e)=>W(document.documentElement,e[0],e[1],e[2]),findByShadowDisplayValue:(...e)=>Y(document.documentElement,e[0],e[1],e[2]),queryAllByShadowAltText:(...e)=>M(document.documentElement,e[0],e[1]),queryByShadowAltText:(...e)=>J(document.documentElement,e[0],e[1]),getAllByShadowAltText:(...e)=>K(document.documentElement,e[0],e[1]),getByShadowAltText:(...e)=>Z(document.documentElement,e[0],e[1]),findAllByShadowAltText:(...e)=>v(document.documentElement,e[0],e[1],e[2]),findByShadowAltText:(...e)=>ee(document.documentElement,e[0],e[1],e[2]),queryAllByShadowTitle:(...e)=>B(document.documentElement,e[0],e[1]),queryByShadowTitle:(...e)=>te(document.documentElement,e[0],e[1]),getAllByShadowTitle:(...e)=>oe(document.documentElement,e[0],e[1]),getByShadowTitle:(...e)=>ne(document.documentElement,e[0],e[1]),findAllByShadowTitle:(...e)=>ae(document.documentElement,e[0],e[1],e[2]),findByShadowTitle:(...e)=>le(document.documentElement,e[0],e[1],e[2]),queryAllByShadowTestId:(...e)=>A(document.documentElement,e[0],e[1]),queryByShadowTestId:(...e)=>re(document.documentElement,e[0],e[1]),getAllByShadowTestId:(...e)=>de(document.documentElement,e[0],e[1]),getByShadowTestId:(...e)=>he(document.documentElement,e[0],e[1]),findAllByShadowTestId:(...e)=>se(document.documentElement,e[0],e[1],e[2]),findByShadowTestId:(...e)=>ce(document.documentElement,e[0],e[1],e[2])};function Ee(){if(typeof ShadowRoot>"u")throw"Your environment does not support shadow roots.";ShadowRoot.prototype.matches==null&&Object.defineProperties(ShadowRoot.prototype,{matches:{get(){return function(e){return e.trim()==="*"?!0:this.querySelector(e)!=null}}}}),ShadowRoot.prototype.outerHTML==null&&Object.defineProperties(ShadowRoot.prototype,{outerHTML:{get(){return this.innerHTML}}})}Ee();var St={...mt,...E};function _t(e){return wt(e,St)}export{we as debug,Pe as deepQuerySelector,Se as deepQuerySelectorAll,v as findAllByShadowAltText,W as findAllByShadowDisplayValue,H as findAllByShadowLabelText,V as findAllByShadowPlaceholderText,L as findAllByShadowRole,se as findAllByShadowTestId,j as findAllByShadowText,ae as findAllByShadowTitle,ee as findByShadowAltText,Y as findByShadowDisplayValue,I as findByShadowLabelText,_ as findByShadowPlaceholderText,q as findByShadowRole,ce as findByShadowTestId,k as findByShadowText,le as findByShadowTitle,K as getAllByShadowAltText,X as getAllByShadowDisplayValue,b as getAllByShadowLabelText,N as getAllByShadowPlaceholderText,P as getAllByShadowRole,de as getAllByShadowTestId,$ as getAllByShadowText,oe as getAllByShadowTitle,h as getAllElementsAndShadowRoots,Z as getByShadowAltText,z as getByShadowDisplayValue,D as getByShadowLabelText,C as getByShadowPlaceholderText,R as getByShadowRole,he as getByShadowTestId,U as getByShadowText,ne as getByShadowTitle,x as logShadowDOM,ve as prettyShadowDOM,M as queryAllByShadowAltText,p as queryAllByShadowDisplayValue,y as queryAllByShadowLabelText,T as queryAllByShadowPlaceholderText,S as queryAllByShadowRole,A as queryAllByShadowTestId,f as queryAllByShadowText,B as queryAllByShadowTitle,J as queryByShadowAltText,G as queryByShadowDisplayValue,Q as queryByShadowLabelText,O as queryByShadowPlaceholderText,g as queryByShadowRole,re as queryByShadowTestId,F as queryByShadowText,te as queryByShadowTitle,it as screen,E as shadowQueries,_t as within}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
{"inputs":{"src/deep-query-selectors.ts":{"bytes":3555,"imports":[]},"src/shadow-queries.ts":{"bytes":10219,"imports":[{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]},"src/pretty-shadow-dom.ts":{"bytes":7926,"imports":[]},"src/log-shadow-dom.ts":{"bytes":626,"imports":[{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"}]},"src/debug.ts":{"bytes":407,"imports":[{"path":"src/log-shadow-dom.ts","kind":"import-statement"}]},"src/shadow-screen.ts":{"bytes":9324,"imports":[{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"}]},"src/trick-dom-testing-library.ts":{"bytes":1227,"imports":[]},"src/types.ts":{"bytes":2196,"imports":[]},"src/index.ts":{"bytes":825,"imports":[{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/log-shadow-dom.ts","kind":"import-statement"},{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"},{"path":"src/shadow-screen.ts","kind":"import-statement"},{"path":"src/trick-dom-testing-library.ts","kind":"import-statement"},{"path":"src/types.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":57030},"dist/index.cjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1692},"src/shadow-queries.ts":{"bytesInOutput":4042},"src/deep-query-selectors.ts":{"bytesInOutput":832},"src/log-shadow-dom.ts":{"bytesInOutput":196},"src/pretty-shadow-dom.ts":{"bytesInOutput":2410},"src/debug.ts":{"bytesInOutput":80},"src/shadow-screen.ts":{"bytesInOutput":3436},"src/trick-dom-testing-library.ts":{"bytesInOutput":395}},"bytes":14730}}} | ||
{"inputs":{"src/deep-query-selectors.ts":{"bytes":3555,"imports":[]},"src/shadow-queries.ts":{"bytes":10219,"imports":[{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]},"src/pretty-shadow-dom.ts":{"bytes":7926,"imports":[]},"src/log-shadow-dom.ts":{"bytes":626,"imports":[{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"}]},"src/debug.ts":{"bytes":407,"imports":[{"path":"src/log-shadow-dom.ts","kind":"import-statement"}]},"src/shadow-screen.ts":{"bytes":9324,"imports":[{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"}]},"src/trick-dom-testing-library.ts":{"bytes":1227,"imports":[]},"src/types.ts":{"bytes":2196,"imports":[]},"src/index.ts":{"bytes":842,"imports":[{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/log-shadow-dom.ts","kind":"import-statement"},{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"},{"path":"src/shadow-screen.ts","kind":"import-statement"},{"path":"src/trick-dom-testing-library.ts","kind":"import-statement"},{"path":"src/types.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":57086},"dist/index.cjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1712},"src/shadow-queries.ts":{"bytesInOutput":4042},"src/deep-query-selectors.ts":{"bytesInOutput":832},"src/log-shadow-dom.ts":{"bytesInOutput":196},"src/pretty-shadow-dom.ts":{"bytesInOutput":2410},"src/debug.ts":{"bytesInOutput":80},"src/shadow-screen.ts":{"bytesInOutput":3437},"src/trick-dom-testing-library.ts":{"bytesInOutput":395}},"bytes":14765}}} |
@@ -1,1 +0,1 @@ | ||
{"inputs":{"src/deep-query-selectors.ts":{"bytes":3555,"imports":[]},"src/shadow-queries.ts":{"bytes":10219,"imports":[{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]},"src/pretty-shadow-dom.ts":{"bytes":7926,"imports":[]},"src/log-shadow-dom.ts":{"bytes":626,"imports":[{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"}]},"src/debug.ts":{"bytes":407,"imports":[{"path":"src/log-shadow-dom.ts","kind":"import-statement"}]},"src/shadow-screen.ts":{"bytes":9324,"imports":[{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"}]},"src/trick-dom-testing-library.ts":{"bytes":1227,"imports":[]},"src/types.ts":{"bytes":2196,"imports":[]},"src/index.ts":{"bytes":825,"imports":[{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/log-shadow-dom.ts","kind":"import-statement"},{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"},{"path":"src/shadow-screen.ts","kind":"import-statement"},{"path":"src/trick-dom-testing-library.ts","kind":"import-statement"},{"path":"src/types.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":55489},"dist/index.js":{"imports":[],"exports":["debug","deepQuerySelector","deepQuerySelectorAll","findAllByShadowAltText","findAllByShadowDisplayValue","findAllByShadowLabelText","findAllByShadowPlaceholderText","findAllByShadowRole","findAllByShadowTestId","findAllByShadowText","findAllByShadowTitle","findByShadowAltText","findByShadowDisplayValue","findByShadowLabelText","findByShadowPlaceholderText","findByShadowRole","findByShadowTestId","findByShadowText","findByShadowTitle","getAllByShadowAltText","getAllByShadowDisplayValue","getAllByShadowLabelText","getAllByShadowPlaceholderText","getAllByShadowRole","getAllByShadowTestId","getAllByShadowText","getAllByShadowTitle","getAllElementsAndShadowRoots","getByShadowAltText","getByShadowDisplayValue","getByShadowLabelText","getByShadowPlaceholderText","getByShadowRole","getByShadowTestId","getByShadowText","getByShadowTitle","logShadowDOM","prettyShadowDOM","queryAllByShadowAltText","queryAllByShadowDisplayValue","queryAllByShadowLabelText","queryAllByShadowPlaceholderText","queryAllByShadowRole","queryAllByShadowTestId","queryAllByShadowText","queryAllByShadowTitle","queryByShadowAltText","queryByShadowDisplayValue","queryByShadowLabelText","queryByShadowPlaceholderText","queryByShadowRole","queryByShadowTestId","queryByShadowText","queryByShadowTitle","screen","within"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":117},"src/shadow-queries.ts":{"bytesInOutput":3944},"src/deep-query-selectors.ts":{"bytesInOutput":832},"src/log-shadow-dom.ts":{"bytesInOutput":193},"src/pretty-shadow-dom.ts":{"bytesInOutput":2409},"src/debug.ts":{"bytesInOutput":80},"src/shadow-screen.ts":{"bytesInOutput":3438},"src/trick-dom-testing-library.ts":{"bytesInOutput":395}},"bytes":12992}}} | ||
{"inputs":{"src/deep-query-selectors.ts":{"bytes":3555,"imports":[]},"src/shadow-queries.ts":{"bytes":10219,"imports":[{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]},"src/pretty-shadow-dom.ts":{"bytes":7926,"imports":[]},"src/log-shadow-dom.ts":{"bytes":626,"imports":[{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"}]},"src/debug.ts":{"bytes":407,"imports":[{"path":"src/log-shadow-dom.ts","kind":"import-statement"}]},"src/shadow-screen.ts":{"bytes":9324,"imports":[{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"}]},"src/trick-dom-testing-library.ts":{"bytes":1227,"imports":[]},"src/types.ts":{"bytes":2196,"imports":[]},"src/index.ts":{"bytes":842,"imports":[{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/debug.ts","kind":"import-statement"},{"path":"src/log-shadow-dom.ts","kind":"import-statement"},{"path":"src/pretty-shadow-dom.ts","kind":"import-statement"},{"path":"src/shadow-screen.ts","kind":"import-statement"},{"path":"src/trick-dom-testing-library.ts","kind":"import-statement"},{"path":"src/types.ts","kind":"import-statement"},{"path":"src/shadow-queries.ts","kind":"import-statement"},{"path":"src/deep-query-selectors.ts","kind":"import-statement"}]}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":55507},"dist/index.js":{"imports":[],"exports":["debug","deepQuerySelector","deepQuerySelectorAll","findAllByShadowAltText","findAllByShadowDisplayValue","findAllByShadowLabelText","findAllByShadowPlaceholderText","findAllByShadowRole","findAllByShadowTestId","findAllByShadowText","findAllByShadowTitle","findByShadowAltText","findByShadowDisplayValue","findByShadowLabelText","findByShadowPlaceholderText","findByShadowRole","findByShadowTestId","findByShadowText","findByShadowTitle","getAllByShadowAltText","getAllByShadowDisplayValue","getAllByShadowLabelText","getAllByShadowPlaceholderText","getAllByShadowRole","getAllByShadowTestId","getAllByShadowText","getAllByShadowTitle","getAllElementsAndShadowRoots","getByShadowAltText","getByShadowDisplayValue","getByShadowLabelText","getByShadowPlaceholderText","getByShadowRole","getByShadowTestId","getByShadowText","getByShadowTitle","logShadowDOM","prettyShadowDOM","queryAllByShadowAltText","queryAllByShadowDisplayValue","queryAllByShadowLabelText","queryAllByShadowPlaceholderText","queryAllByShadowRole","queryAllByShadowTestId","queryAllByShadowText","queryAllByShadowTitle","queryByShadowAltText","queryByShadowDisplayValue","queryByShadowLabelText","queryByShadowPlaceholderText","queryByShadowRole","queryByShadowTestId","queryByShadowText","queryByShadowTitle","screen","shadowQueries","within"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":117},"src/shadow-queries.ts":{"bytesInOutput":3944},"src/deep-query-selectors.ts":{"bytesInOutput":832},"src/log-shadow-dom.ts":{"bytesInOutput":193},"src/pretty-shadow-dom.ts":{"bytesInOutput":2409},"src/debug.ts":{"bytesInOutput":80},"src/shadow-screen.ts":{"bytesInOutput":3438},"src/trick-dom-testing-library.ts":{"bytesInOutput":395}},"bytes":13011}}} |
{ | ||
"name": "shadow-dom-testing-library", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "An extension of DOM-testing-library to provide hooks into the shadow dom", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -254,1 +254,30 @@ # Why? | ||
``` | ||
## ShadowQueries | ||
Perhaps you don't want the extended screen. That's fine. To | ||
import just the shadowQueries you can do so like this: | ||
```js | ||
import { shadowQueries } from "shadow-dom-testing-library"; | ||
test("findByShadowRole", async () => { | ||
render(<Button />); | ||
const btn = await shadowQueries.findByShadowRole("button"); | ||
expect(btn).toBeInTheDocument(); | ||
}); | ||
``` | ||
You could also use this method to extend your own screen. | ||
```js | ||
import { shadowQueries } from "shadow-dom-testing-library"; | ||
import { screen as DOMScreen } from "@testing-library/dom"; | ||
const screen = { | ||
...DOMScreen, | ||
...shadowQueries, | ||
}; | ||
screen.getByShadowRole("button"); | ||
``` |
@@ -33,2 +33,3 @@ import { queries, within } from "@testing-library/dom"; | ||
shadowWithin as within, | ||
shadowQueries, | ||
debug, | ||
@@ -35,0 +36,0 @@ logShadowDOM, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
256219
1832
283