@ctrl/dom-jest-environment 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/NOTICE +0 -37
  2. package/dist/index.js +1 -1
  3. package/package.json +2 -2
package/NOTICE CHANGED
@@ -7,10 +7,6 @@ with ported code names the upstream file it came from in a comment ("Port of ...
7
7
  from ..."), and those files have been modified from the originals. Each project's copyright
8
8
  notice is listed with its entry; the license texts are at the end of this file.
9
9
 
10
- ==================================================================================================
11
- Included in the published packages
12
- ==================================================================================================
13
-
14
10
  @testing-library/dom 10.4.2 (MIT)
15
11
  Copyright (c) 2017 Kent C. Dodds
16
12
  https://github.com/testing-library/dom-testing-library
@@ -84,28 +80,6 @@ Source comments throughout quote the specifications they implement (WHATWG, W3C,
84
80
  others), with a link to each section. Quoted text is © its authors; WHATWG specifications are
85
81
  licensed under CC BY 4.0, W3C specifications under the W3C Software and Document License.
86
82
 
87
- ==================================================================================================
88
- Tests and test data (in the repository only, not in the published packages)
89
- ==================================================================================================
90
-
91
- web-platform-tests (BSD-3-Clause)
92
- Copyright © web-platform-tests contributors
93
- https://github.com/web-platform-tests/wpt
94
- Ported dom, html, selectors, css and accname tests (packages/*/test/wpt)
95
-
96
- html5lib-tests (MIT)
97
- Copyright (c) 2006-2013 James Graham, Geoffrey Sneddon, and other contributors
98
- https://github.com/html5lib/html5lib-tests
99
- Tokenizer and tree construction suites (packages/dom/test/parser/fixtures/html5lib)
100
-
101
- css-tokenizer-tests 1.4.0 (MIT, as its npm package @rmenke/css-tokenizer-tests declares)
102
- Copyright (c) Romain Menke
103
- https://github.com/romainmenke/css-tokenizer-tests
104
- packages/dom/test/css/fixtures/css-tokenizer-tests.json
105
-
106
- The test suites of @testing-library/dom, /react, /user-event and /jest-dom, dom-accessibility-api
107
- and aria-query (copyrights and licenses as above) are ported under packages/*/test/upstream.
108
-
109
83
  ==================================================================================================
110
84
  License texts
111
85
  ==================================================================================================
@@ -146,17 +120,6 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
146
120
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
147
121
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
148
122
 
149
- BSD 3-Clause License (web-platform-tests)
150
- -----------------------------------------
151
-
152
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
153
-
154
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
155
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
156
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
157
-
158
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
159
-
160
123
  Apache License 2.0 (aria-query, Playwright)
161
124
  -------------------------------------------
162
125
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{constants as e,createContext as t}from"node:vm";import{LegacyFakeTimers as n,ModernFakeTimers as r}from"@jest/fake-timers";import{ModuleMocker as i}from"jest-mock";import{installCommonGlobals as a}from"jest-util";import*as o from"@ctrl/dom";import*as s from"@ctrl/dom/internal";function debugEnabled(){let e=process.env.CTRL_DOM_DEBUG?.trim().toLowerCase();return e===`aria`||e===`compact`||e===`html`}function failureSnapshotHandler(e){if(!debugEnabled())return;let t=null;return async n=>{if(n.name!==`test_start`&&n.name!==`test_fn_failure`)return;t??=await import(`@ctrl/dom/testing-library/agent`);let r=e();if(r==null)return;if(n.name===`test_start`){t.resetFailureSnapshot(r);return}let i=n.error,a=typeof i==`object`&&i&&typeof i.message==`string`?i.message:``,o=t.captureFailureSnapshot(r);o!==null&&t.appendToErrorMessage(i,t.formatFailureSnapshot(o,a))}}const c=Symbol.for(`ctrl-dom.dom.modules`),l=/* @__PURE__ */ new Set([`fetch`,`Request`,`Response`]),u=/* @__PURE__ */ new Set([`GLOBAL`,`root`,`global`,`globalThis`,`Buffer`,`ArrayBuffer`,`Uint8Array`,`jest-symbol-do-not-touch`,`localStorage`,`sessionStorage`]),d=/* @__PURE__ */ new Map([[`fetch`,!0],[`Request`,!1],[`Response`,!1],[`Headers`,!1],[`FormData`,!1],[`WebSocket`,!1],[`EventSource`,!1],[`MessageEvent`,!1],[`CloseEvent`,!1]]);let f=null;function nodeGlobalDescriptors(){return f??=Object.getOwnPropertyNames(globalThis).filter(e=>!u.has(e)).map(e=>[e,d.has(e)?null:Object.getOwnPropertyDescriptor(globalThis,e)])}function installNodeGlobals(e,t){let n=new Set(Object.getOwnPropertyNames(e)),r=globalThis;for(let[i,a]of nodeGlobalDescriptors()){if(n.has(i)||t.has(i))continue;let o=a===null?d.get(i):a.enumerable;if(a===null||a.configurable){let settle=t=>Object.defineProperty(e,i,{value:t,writable:!0,enumerable:o,configurable:!0});Object.defineProperty(e,i,{get(){let e=r[i];return settle(e),e},set:settle,enumerable:o,configurable:!0})}else Object.defineProperty(e,i,a)}e.global=e,e.Buffer=Buffer,e.ArrayBuffer=ArrayBuffer,e.Uint8Array=Uint8Array}function reportToHost(e){process.emit(`uncaughtException`,e,`uncaughtException`)}function forwardNotImplemented(e){return(t,n)=>{let r=e.console;n!==`jsdom-26`&&r.error(t.stack,t.detail),r.error(t)}}const p=[`Error`,`TypeError`,`RangeError`,`SyntaxError`,`ReferenceError`,`EvalError`,`URIError`];function bridgeErrorRealms(e){for(let t of p){let n=e[t],r=globalThis[t];typeof n==`function`&&n!==r&&Object.defineProperty(n,Symbol.hasInstance,{value:e=>Function.prototype[Symbol.hasInstance].call(n,e)||e instanceof r,configurable:!0})}}function createDom(e){return{window:e,reconfigure(t){if(t.windowTop!==void 0)throw TypeError(`@ctrl/dom-jest-environment: dom.reconfigure() does not support windowTop`);if(t.url===void 0)return;let n=URL.parse(String(t.url));if(n===null)throw TypeError(`Could not parse "${t.url}" as a URL`);e._setURL(n)}}}var CtrlDomEnvironment=class{context;global;fakeTimers;fakeTimersModern;moduleMocker;customExportConditions;ctrlDomWindow;dom;clock;#e=null;constructor(u,d){let{projectConfig:f}=u,{customExportConditions:p,nodeFetch:m,timeSkip:h,...g}=f.testEnvironmentOptions??{};this.customExportConditions=p??[`browser`];let _=t(e.DONT_CONTEXTIFY);this.context=_;let v=_;this.global=v,installNodeGlobals(v,m===!0?/* @__PURE__ */ new Set:l),a(this.global,f.globals);let y=v.Symbol;`asyncDispose`in y||(Object.defineProperty(y,"asyncDispose",{value:Symbol.for(`nodejs.asyncDispose`)}),Object.defineProperty(y,"dispose",{value:Symbol.for(`nodejs.dispose`)})),v.Error.stackTraceLimit=100;let b=o.createWindow({...g,compat:g.compat??`jsdom-26`,url:g.url??`http://localhost/`});this.ctrlDomWindow=b,this.dom=createDom(b),s.captureInterfaceBaseline(),o.installGlobals(b,v),Object.defineProperty(v,c,{value:{dom:o,internal:s},configurable:!0,enumerable:!1,writable:!1}),bridgeErrorRealms(v);let x=process.env.CTRL_DOM_TIME_SKIP,S=x===`1`||x!==`0`&&h!==!1;this.clock=s.installClock(new s.VirtualClock({skip:S}),v).clock,this.moduleMocker=new i(this.global),this.fakeTimers=new n({config:f,global:this.global,moduleMocker:this.moduleMocker,timerConfig:{idToRef:e=>e,refToId:e=>e}}),this.fakeTimersModern=new r({config:f,global:this.global}),s.guardInterfaceDefinitions(v),s.setUncaughtExceptionHandler(reportToHost),s.setNotImplementedHandler(forwardNotImplemented(v));let C=failureSnapshotHandler(()=>this.ctrlDomWindow?.document);C!==void 0&&(this.handleTestEvent=C),this.#e=s.subscribeTestFailures(()=>this.ctrlDomWindow?.document)}async setup(){}exportConditions(){return this.customExportConditions}getVmContext(){return this.context}async teardown(){this.#e?.(),this.#e=null,s.setUncaughtExceptionHandler(null),s.setNotImplementedHandler(null),this.fakeTimers?.dispose(),this.fakeTimersModern?.dispose(),this.ctrlDomWindow?.close(),this.ctrlDomWindow=null,this.clock?.dispose(),this.clock=null,this.dom=null,s.restoreInterfaces(),this.context=null,this.fakeTimers=null,this.fakeTimersModern=null}};const m=CtrlDomEnvironment;export{c as CTRL_DOM_MODULES,m as TestEnvironment,CtrlDomEnvironment as default};
1
+ import{constants as e,createContext as t}from"node:vm";import{LegacyFakeTimers as n,ModernFakeTimers as r}from"@jest/fake-timers";import{ModuleMocker as i}from"jest-mock";import{installCommonGlobals as a}from"jest-util";import*as o from"@ctrl/dom";import*as s from"@ctrl/dom/internal";function debugEnabled(){let e=process.env.CTRL_DOM_DEBUG?.trim().toLowerCase();return e===`aria`||e===`compact`||e===`html`}function failureSnapshotHandler(e){if(!debugEnabled())return;let t=null;return async n=>{if(n.name!==`test_start`&&n.name!==`test_fn_failure`)return;t??=await import(`@ctrl/dom/testing-library/agent`);let r=e();if(r==null)return;if(n.name===`test_start`){t.resetFailureSnapshot(r);return}let i=n.error,a=typeof i==`object`&&i&&typeof i.message==`string`?i.message:``,o=t.captureFailureSnapshot(r);o!==null&&t.appendToErrorMessage(i,t.formatFailureSnapshot(o,a))}}const c=Symbol.for(`ctrl-dom.dom.modules`),l=/* @__PURE__ */ new Set([`fetch`,`Request`,`Response`]),u=/* @__PURE__ */ new Set([`GLOBAL`,`root`,`global`,`globalThis`,`Buffer`,`ArrayBuffer`,`Uint8Array`,`jest-symbol-do-not-touch`,`localStorage`,`sessionStorage`]),d=/* @__PURE__ */ new Map([[`fetch`,!0]]);for(let e of/* @__PURE__ */ `Request.Response.Headers.FormData.WebSocket.EventSource.MessageEvent.CloseEvent.ErrorEvent.ReadableStream.ReadableStreamDefaultReader.ReadableStreamBYOBReader.ReadableStreamBYOBRequest.ReadableByteStreamController.ReadableStreamDefaultController.TransformStream.TransformStreamDefaultController.WritableStream.WritableStreamDefaultWriter.WritableStreamDefaultController.ByteLengthQueuingStrategy.CountQueuingStrategy.TextEncoderStream.TextDecoderStream.CompressionStream.DecompressionStream.Crypto.CryptoKey.SubtleCrypto.MessageChannel.MessagePort.BroadcastChannel.Performance.PerformanceEntry.PerformanceMark.PerformanceMeasure.PerformanceObserver.PerformanceObserverEntryList.PerformanceResourceTiming.Storage.Navigator.QuotaExceededError.File.AbortController.AbortSignal`.split(`.`))d.set(e,!1);let f=null;function nodeGlobalDescriptors(){return f??=Object.getOwnPropertyNames(globalThis).filter(e=>!u.has(e)).map(e=>[e,d.has(e)?null:Object.getOwnPropertyDescriptor(globalThis,e)])}function installNodeGlobals(e,t){let n=new Set(Object.getOwnPropertyNames(e)),r=globalThis;for(let[i,a]of nodeGlobalDescriptors()){if(n.has(i)||t.has(i))continue;let o=a===null?d.get(i):a.enumerable;if(a===null||a.configurable){let settle=t=>Object.defineProperty(e,i,{value:t,writable:!0,enumerable:o,configurable:!0});Object.defineProperty(e,i,{get(){let e=r[i];return settle(e),e},set:settle,enumerable:o,configurable:!0})}else Object.defineProperty(e,i,a)}e.global=e,e.Buffer=Buffer,e.ArrayBuffer=ArrayBuffer,e.Uint8Array=Uint8Array}function reportToHost(e){process.emit(`uncaughtException`,e,`uncaughtException`)}function forwardNotImplemented(e){return(t,n)=>{let r=e.console;n!==`jsdom-26`&&r.error(t.stack,t.detail),r.error(t)}}const p=[`Error`,`TypeError`,`RangeError`,`SyntaxError`,`ReferenceError`,`EvalError`,`URIError`];function bridgeErrorRealms(e){for(let t of p){let n=e[t],r=globalThis[t];typeof n==`function`&&n!==r&&Object.defineProperty(n,Symbol.hasInstance,{value:e=>Function.prototype[Symbol.hasInstance].call(n,e)||e instanceof r,configurable:!0})}}function createDom(e){return{window:e,reconfigure(t){if(t.windowTop!==void 0)throw TypeError(`@ctrl/dom-jest-environment: dom.reconfigure() does not support windowTop`);if(t.url===void 0)return;let n=URL.parse(String(t.url));if(n===null)throw TypeError(`Could not parse "${t.url}" as a URL`);e._setURL(n)}}}var CtrlDomEnvironment=class{context;global;fakeTimers;fakeTimersModern;moduleMocker;customExportConditions;ctrlDomWindow;dom;clock;#e=null;constructor(u,d){let{projectConfig:f}=u,{customExportConditions:p,nodeFetch:m,timeSkip:h,...g}=f.testEnvironmentOptions??{};this.customExportConditions=p??[`browser`];let _=t(e.DONT_CONTEXTIFY);this.context=_;let v=_;this.global=v,installNodeGlobals(v,m===!0?/* @__PURE__ */ new Set:l),a(this.global,f.globals);let y=v.Symbol;`asyncDispose`in y||(Object.defineProperty(y,"asyncDispose",{value:Symbol.for(`nodejs.asyncDispose`)}),Object.defineProperty(y,"dispose",{value:Symbol.for(`nodejs.dispose`)})),v.Error.stackTraceLimit=100;let b=o.createWindow({...g,compat:g.compat??`jsdom-26`,url:g.url??`http://localhost/`});this.ctrlDomWindow=b,this.dom=createDom(b),o.installGlobals(b,v),s.captureInterfaceBaseline(),Object.defineProperty(v,c,{value:{dom:o,internal:s},configurable:!0,enumerable:!1,writable:!1}),bridgeErrorRealms(v);let x=process.env.CTRL_DOM_TIME_SKIP,S=x===`1`||x!==`0`&&h!==!1;this.clock=s.installClock(new s.VirtualClock({skip:S}),v).clock,this.moduleMocker=new i(this.global),this.fakeTimers=new n({config:f,global:this.global,moduleMocker:this.moduleMocker,timerConfig:{idToRef:e=>e,refToId:e=>e}}),this.fakeTimersModern=new r({config:f,global:this.global}),s.guardInterfaceDefinitions(v),s.setUncaughtExceptionHandler(reportToHost),s.setNotImplementedHandler(forwardNotImplemented(v));let C=failureSnapshotHandler(()=>this.ctrlDomWindow?.document);C!==void 0&&(this.handleTestEvent=C),this.#e=s.subscribeTestFailures(()=>this.ctrlDomWindow?.document)}async setup(){}exportConditions(){return this.customExportConditions}getVmContext(){return this.context}async teardown(){this.#e?.(),this.#e=null,s.setUncaughtExceptionHandler(null),s.setNotImplementedHandler(null),this.fakeTimers?.dispose(),this.fakeTimersModern?.dispose(),this.ctrlDomWindow?.close(),this.ctrlDomWindow=null,this.clock?.dispose(),this.clock=null,this.dom=null,s.restoreInterfaces(),this.context=null,this.fakeTimers=null,this.fakeTimersModern=null}};const m=CtrlDomEnvironment;export{c as CTRL_DOM_MODULES,m as TestEnvironment,CtrlDomEnvironment as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/dom-jest-environment",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Jest environment for @ctrl/dom, the fast DOM for testing React components (testEnvironment: \"@ctrl/dom-jest-environment\", or preset: \"@ctrl/dom\").",
5
5
  "keywords": [
6
6
  "jest",
@@ -52,7 +52,7 @@
52
52
  "jest-util": "^30.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ctrl/dom": "^0.1.8",
55
+ "@ctrl/dom": "^0.1.10",
56
56
  "jest": ">=30.0.0"
57
57
  }
58
58
  }