@ctrl/dom 0.0.0-stage → 0.1.0
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.
- package/LICENSE +21 -0
- package/NOTICE +338 -0
- package/README.md +362 -2
- package/dist/aria/_chunks/roles-list-CYZF-l9K.js +1503 -0
- package/dist/aria/_chunks/roles-list-D4WCyRO_.cjs +1754 -0
- package/dist/aria/index.cjs +232 -0
- package/dist/aria/index.js +198 -0
- package/dist/aria/internal.cjs +69 -0
- package/dist/aria/internal.js +30 -0
- package/dist/aria/types/accname.d.ts +40 -0
- package/dist/aria/types/data/aria-query.d.ts +61 -0
- package/dist/aria/types/data/aria-query.generated.d.ts +2 -0
- package/dist/aria/types/forms.d.ts +25 -0
- package/dist/aria/types/hidden.d.ts +38 -0
- package/dist/aria/types/index.d.ts +46 -0
- package/dist/aria/types/internal.d.ts +15 -0
- package/dist/aria/types/role.d.ts +27 -0
- package/dist/aria/types/roles-list.d.ts +18 -0
- package/dist/aria/types/states.d.ts +29 -0
- package/dist/aria/types/style.d.ts +18 -0
- package/dist/aria/types/tree.d.ts +20 -0
- package/dist/bridge/index.cjs +3 -0
- package/dist/bridge/index.js +4 -0
- package/dist/bridge/internal.cjs +3 -0
- package/dist/bridge/internal.js +4 -0
- package/dist/cli/_chunks/report-DdncYfuJ.js +93 -0
- package/dist/cli/ctrl-dom.js +199 -0
- package/dist/cli/jest-reporter.js +55 -0
- package/dist/cli/vitest-reporter.js +81 -0
- package/dist/dom/_chunks/src-DWP2w3IQ.js +47516 -0
- package/dist/dom/index.js +3 -0
- package/dist/dom/internal.js +434 -0
- package/dist/dom/types/collections/DOMStringMap.d.ts +8 -0
- package/dist/dom/types/collections/DOMTokenList.d.ts +33 -0
- package/dist/dom/types/collections/HTMLCollection.d.ts +62 -0
- package/dist/dom/types/collections/NamedNodeMap.d.ts +22 -0
- package/dist/dom/types/collections/NodeList.d.ts +43 -0
- package/dist/dom/types/collections/indexed.d.ts +8 -0
- package/dist/dom/types/collections/iterator.d.ts +8 -0
- package/dist/dom/types/css/CSS.d.ts +21 -0
- package/dist/dom/types/css/CSSStyleDeclaration.d.ts +57 -0
- package/dist/dom/types/css/cascade.d.ts +159 -0
- package/dist/dom/types/css/colors.d.ts +28 -0
- package/dist/dom/types/css/computed.d.ts +22 -0
- package/dist/dom/types/css/cssom.d.ts +363 -0
- package/dist/dom/types/css/data/properties.d.ts +1 -0
- package/dist/dom/types/css/declarations.d.ts +40 -0
- package/dist/dom/types/css/index.d.ts +5 -0
- package/dist/dom/types/css/inline-count.d.ts +2 -0
- package/dist/dom/types/css/internal.d.ts +11 -0
- package/dist/dom/types/css/layout-mode.d.ts +4 -0
- package/dist/dom/types/css/layout.d.ts +63 -0
- package/dist/dom/types/css/media.d.ts +55 -0
- package/dist/dom/types/css/parser.d.ts +93 -0
- package/dist/dom/types/css/properties.d.ts +28 -0
- package/dist/dom/types/css/resize-observer.d.ts +19 -0
- package/dist/dom/types/css/selector-info.d.ts +13 -0
- package/dist/dom/types/css/shorthands.d.ts +33 -0
- package/dist/dom/types/css/stylesheets.d.ts +93 -0
- package/dist/dom/types/css/supports.d.ts +4 -0
- package/dist/dom/types/css/tokenizer.d.ts +91 -0
- package/dist/dom/types/css/values.d.ts +91 -0
- package/dist/dom/types/css/view.d.ts +44 -0
- package/dist/dom/types/events/DataTransfer.d.ts +62 -0
- package/dist/dom/types/events/Event.d.ts +115 -0
- package/dist/dom/types/events/EventTarget.d.ts +22 -0
- package/dist/dom/types/events/UIEvents.d.ts +308 -0
- package/dist/dom/types/events/activation.d.ts +7 -0
- package/dist/dom/types/events/convert.d.ts +16 -0
- package/dist/dom/types/events/createEvent.d.ts +3 -0
- package/dist/dom/types/events/dispatch.d.ts +39 -0
- package/dist/dom/types/events/events.d.ts +200 -0
- package/dist/dom/types/events/fire.d.ts +21 -0
- package/dist/dom/types/events/handlers.d.ts +14 -0
- package/dist/dom/types/events/listeners.d.ts +32 -0
- package/dist/dom/types/events/report.d.ts +10 -0
- package/dist/dom/types/html/HTMLElement.d.ts +126 -0
- package/dist/dom/types/html/MathMLElement.d.ts +6 -0
- package/dist/dom/types/html/SVGElement.d.ts +145 -0
- package/dist/dom/types/html/anchor.d.ts +16 -0
- package/dist/dom/types/html/aria-reflection.d.ts +14 -0
- package/dist/dom/types/html/collection.d.ts +5 -0
- package/dist/dom/types/html/custom-elements.d.ts +129 -0
- package/dist/dom/types/html/elements.d.ts +202 -0
- package/dist/dom/types/html/events.d.ts +22 -0
- package/dist/dom/types/html/focus.d.ts +63 -0
- package/dist/dom/types/html/forms/FileList.d.ts +1 -0
- package/dist/dom/types/html/forms/FormData.d.ts +7 -0
- package/dist/dom/types/html/forms/HTMLButtonElement.d.ts +36 -0
- package/dist/dom/types/html/forms/HTMLFieldSetElement.d.ts +29 -0
- package/dist/dom/types/html/forms/HTMLFormElement.d.ts +61 -0
- package/dist/dom/types/html/forms/HTMLInputElement.d.ts +204 -0
- package/dist/dom/types/html/forms/HTMLLabelElement.d.ts +15 -0
- package/dist/dom/types/html/forms/HTMLOptionElement.d.ts +61 -0
- package/dist/dom/types/html/forms/HTMLOutputElement.d.ts +74 -0
- package/dist/dom/types/html/forms/HTMLSelectElement.d.ts +96 -0
- package/dist/dom/types/html/forms/HTMLTextAreaElement.d.ts +82 -0
- package/dist/dom/types/html/forms/autofill.d.ts +10 -0
- package/dist/dom/types/html/forms/collections.d.ts +112 -0
- package/dist/dom/types/html/forms/common.d.ts +36 -0
- package/dist/dom/types/html/forms/face.d.ts +59 -0
- package/dist/dom/types/html/forms/form-associated.d.ts +46 -0
- package/dist/dom/types/html/forms/form-submission.d.ts +55 -0
- package/dist/dom/types/html/forms/index.d.ts +17 -0
- package/dist/dom/types/html/forms/input-type.d.ts +50 -0
- package/dist/dom/types/html/forms/microsyntaxes.d.ts +52 -0
- package/dist/dom/types/html/forms/state.d.ts +54 -0
- package/dist/dom/types/html/forms/ui.d.ts +35 -0
- package/dist/dom/types/html/forms/user-validity.d.ts +19 -0
- package/dist/dom/types/html/forms/validation.d.ts +76 -0
- package/dist/dom/types/html/index.d.ts +13 -0
- package/dist/dom/types/html/innerText.d.ts +9 -0
- package/dist/dom/types/html/interactive.d.ts +43 -0
- package/dist/dom/types/html/invokers.d.ts +39 -0
- package/dist/dom/types/html/media.d.ts +86 -0
- package/dist/dom/types/html/reflect.d.ts +67 -0
- package/dist/dom/types/html/registry.d.ts +9 -0
- package/dist/dom/types/html/resources.d.ts +55 -0
- package/dist/dom/types/html/shared.d.ts +22 -0
- package/dist/dom/types/html/slot.d.ts +15 -0
- package/dist/dom/types/html/template.d.ts +18 -0
- package/dist/dom/types/html/top-layer.d.ts +73 -0
- package/dist/dom/types/index.d.ts +50 -0
- package/dist/dom/types/internal.d.ts +61 -0
- package/dist/dom/types/keys.d.ts +209 -0
- package/dist/dom/types/nodes/Attr.d.ts +25 -0
- package/dist/dom/types/nodes/CharacterData.d.ts +35 -0
- package/dist/dom/types/nodes/Document.d.ts +169 -0
- package/dist/dom/types/nodes/DocumentFragment.d.ts +12 -0
- package/dist/dom/types/nodes/DocumentType.d.ts +17 -0
- package/dist/dom/types/nodes/Element.d.ts +142 -0
- package/dist/dom/types/nodes/Node.d.ts +112 -0
- package/dist/dom/types/nodes/NodeImpl.d.ts +90 -0
- package/dist/dom/types/nodes/ShadowRoot.d.ts +43 -0
- package/dist/dom/types/nodes/attr-nodes.d.ts +8 -0
- package/dist/dom/types/nodes/attributes.d.ts +46 -0
- package/dist/dom/types/nodes/cache.d.ts +38 -0
- package/dist/dom/types/nodes/character-data.d.ts +5 -0
- package/dist/dom/types/nodes/clone.d.ts +5 -0
- package/dist/dom/types/nodes/constants.d.ts +52 -0
- package/dist/dom/types/nodes/create.d.ts +42 -0
- package/dist/dom/types/nodes/derived.d.ts +26 -0
- package/dist/dom/types/nodes/inspect.d.ts +2 -0
- package/dist/dom/types/nodes/mixins.d.ts +41 -0
- package/dist/dom/types/nodes/names.d.ts +15 -0
- package/dist/dom/types/nodes/slots.d.ts +38 -0
- package/dist/dom/types/nodes/tags.d.ts +8 -0
- package/dist/dom/types/nodes/traverse.d.ts +21 -0
- package/dist/dom/types/nodes/tree.d.ts +47 -0
- package/dist/dom/types/observers/MutationObserver.d.ts +33 -0
- package/dist/dom/types/observers/MutationRecord.d.ts +17 -0
- package/dist/dom/types/observers/queue.d.ts +45 -0
- package/dist/dom/types/parser/entities-data.d.ts +3 -0
- package/dist/dom/types/parser/entities.d.ts +11 -0
- package/dist/dom/types/parser/index.d.ts +34 -0
- package/dist/dom/types/parser/tags.d.ts +182 -0
- package/dist/dom/types/parser/tokenizer.d.ts +109 -0
- package/dist/dom/types/parser/treebuilder.d.ts +271 -0
- package/dist/dom/types/parser/xml.d.ts +14 -0
- package/dist/dom/types/selectors/compile.d.ts +154 -0
- package/dist/dom/types/selectors/filter.d.ts +21 -0
- package/dist/dom/types/selectors/html-predicates.d.ts +1 -0
- package/dist/dom/types/selectors/index.d.ts +16 -0
- package/dist/dom/types/selectors/internal.d.ts +87 -0
- package/dist/dom/types/selectors/parser.d.ts +310 -0
- package/dist/dom/types/selectors/serialize.d.ts +20 -0
- package/dist/dom/types/selectors/state.d.ts +43 -0
- package/dist/dom/types/serializer/index.d.ts +29 -0
- package/dist/dom/types/trace.d.ts +51 -0
- package/dist/dom/types/traversal/Range.d.ts +113 -0
- package/dist/dom/types/traversal/Selection.d.ts +45 -0
- package/dist/dom/types/traversal/TreeWalker.d.ts +77 -0
- package/dist/dom/types/traversal/live.d.ts +46 -0
- package/dist/dom/types/webidl-runtime.d.ts +18 -0
- package/dist/dom/types/webidl.d.ts +34 -0
- package/dist/dom/types/window/DOMStringList.d.ts +14 -0
- package/dist/dom/types/window/FileList.d.ts +11 -0
- package/dist/dom/types/window/FileReader.d.ts +27 -0
- package/dist/dom/types/window/History.d.ts +43 -0
- package/dist/dom/types/window/Location.d.ts +46 -0
- package/dist/dom/types/window/Navigator.d.ts +79 -0
- package/dist/dom/types/window/Screen.d.ts +27 -0
- package/dist/dom/types/window/Storage.d.ts +28 -0
- package/dist/dom/types/window/Window.d.ts +329 -0
- package/dist/dom/types/window/abort.d.ts +4 -0
- package/dist/dom/types/window/browsing-context.d.ts +12 -0
- package/dist/dom/types/window/clock.d.ts +153 -0
- package/dist/dom/types/window/compat.d.ts +34 -0
- package/dist/dom/types/window/cookies.d.ts +21 -0
- package/dist/dom/types/window/current.d.ts +7 -0
- package/dist/dom/types/window/document.d.ts +19 -0
- package/dist/dom/types/window/events.d.ts +11 -0
- package/dist/dom/types/window/fallbacks.d.ts +20 -0
- package/dist/dom/types/window/geometry.d.ts +133 -0
- package/dist/dom/types/window/globals.d.ts +7 -0
- package/dist/dom/types/window/hooks.d.ts +22 -0
- package/dist/dom/types/window/host-originals.d.ts +9 -0
- package/dist/dom/types/window/interfaces.d.ts +13 -0
- package/dist/dom/types/window/isolation.d.ts +20 -0
- package/dist/dom/types/window/media.d.ts +33 -0
- package/dist/dom/types/window/not-implemented.d.ts +23 -0
- package/dist/dom/types/window/observers.d.ts +42 -0
- package/dist/dom/types/window/origin.d.ts +3 -0
- package/dist/dom/types/window/timers.d.ts +28 -0
- package/dist/dom/types/window/xhr.d.ts +108 -0
- package/dist/jest-dom/_chunks/matchers-CDnnXUfG.js +2211 -0
- package/dist/jest-dom/_chunks/matchers-D988Ducb.cjs +2516 -0
- package/dist/jest-dom/index.cjs +5 -0
- package/dist/jest-dom/index.js +6 -0
- package/dist/jest-dom/jest-globals.cjs +6 -0
- package/dist/jest-dom/jest-globals.js +7 -0
- package/dist/jest-dom/matchers.cjs +53 -0
- package/dist/jest-dom/matchers.js +3 -0
- package/dist/jest-dom/types/bun.d.ts +13 -0
- package/dist/jest-dom/types/index.d.ts +3 -0
- package/dist/jest-dom/types/jest-globals.d.ts +13 -0
- package/dist/jest-dom/types/jest.d.ts +15 -0
- package/dist/jest-dom/types/matchers-standalone.d.ts +32 -0
- package/dist/jest-dom/types/matchers.d.ts +1079 -0
- package/dist/jest-dom/types/package.json +1 -0
- package/dist/jest-dom/types/vitest.d.ts +16 -0
- package/dist/jest-dom/vitest.cjs +6 -0
- package/dist/jest-dom/vitest.js +7 -0
- package/dist/react/_chunks/pure-DZ97z2oT.cjs +498 -0
- package/dist/react/_chunks/pure-PtE2hivW.js +420 -0
- package/dist/react/dont-cleanup-after-each.cjs +3 -0
- package/dist/react/dont-cleanup-after-each.js +4 -0
- package/dist/react/index.cjs +47 -0
- package/dist/react/index.js +35 -0
- package/dist/react/pure.cjs +17 -0
- package/dist/react/pure.js +5 -0
- package/dist/react/types/act-compat.d.ts +6 -0
- package/dist/react/types/config.d.ts +9 -0
- package/dist/react/types/dont-cleanup-after-each.d.ts +1 -0
- package/dist/react/types/dtl.d.ts +1 -0
- package/dist/react/types/fire-event.d.ts +3 -0
- package/dist/react/types/index.d.ts +1 -0
- package/dist/react/types/pure.d.ts +136 -0
- package/dist/register/index.js +11 -0
- package/dist/register/pure.js +147 -0
- package/dist/register/types/index.d.ts +1 -0
- package/dist/register/types/pure.d.ts +36 -0
- package/dist/testing-library/_chunks/aria-snapshot-diff-D7PzpXew.cjs +1170 -0
- package/dist/testing-library/_chunks/aria-snapshot-diff-Q8Wj33K0.js +985 -0
- package/dist/testing-library/agent.cjs +721 -0
- package/dist/testing-library/agent.js +713 -0
- package/dist/testing-library/index.cjs +2469 -0
- package/dist/testing-library/index.js +2390 -0
- package/dist/testing-library/types/agent.d.ts +56 -0
- package/dist/testing-library/types/aria-role.d.ts +99 -0
- package/dist/testing-library/types/aria-snapshot.d.ts +43 -0
- package/dist/testing-library/types/config.d.ts +27 -0
- package/dist/testing-library/types/events.d.ts +118 -0
- package/dist/testing-library/types/get-node-text.d.ts +1 -0
- package/dist/testing-library/types/get-queries-for-element.d.ts +182 -0
- package/dist/testing-library/types/index.d.ts +24 -0
- package/dist/testing-library/types/matches.d.ts +46 -0
- package/dist/testing-library/types/pretty-dom.d.ts +37 -0
- package/dist/testing-library/types/queries.d.ts +315 -0
- package/dist/testing-library/types/query-helpers.d.ts +112 -0
- package/dist/testing-library/types/role-helpers.d.ts +19 -0
- package/dist/testing-library/types/screen.d.ts +30 -0
- package/dist/testing-library/types/suggestions.d.ts +46 -0
- package/dist/testing-library/types/wait-for-element-to-be-removed.d.ts +6 -0
- package/dist/testing-library/types/wait-for.d.ts +12 -0
- package/dist/user-event/index.cjs +3910 -0
- package/dist/user-event/index.js +3885 -0
- package/dist/user-event/types/clipboard/copy.d.ts +2 -0
- package/dist/user-event/types/clipboard/cut.d.ts +2 -0
- package/dist/user-event/types/clipboard/index.d.ts +3 -0
- package/dist/user-event/types/clipboard/paste.d.ts +3 -0
- package/dist/user-event/types/convenience/click.d.ts +5 -0
- package/dist/user-event/types/convenience/hover.d.ts +4 -0
- package/dist/user-event/types/convenience/index.d.ts +3 -0
- package/dist/user-event/types/convenience/tab.d.ts +4 -0
- package/dist/user-event/types/ctrl-dom.d.ts +50 -0
- package/dist/user-event/types/document/UI.d.ts +35 -0
- package/dist/user-event/types/document/copySelection.d.ts +2 -0
- package/dist/user-event/types/document/getValueOrTextContent.d.ts +2 -0
- package/dist/user-event/types/document/index.d.ts +5 -0
- package/dist/user-event/types/document/interceptor.d.ts +20 -0
- package/dist/user-event/types/document/patchFocus.d.ts +7 -0
- package/dist/user-event/types/document/prepareDocument.d.ts +2 -0
- package/dist/user-event/types/document/trackValue.d.ts +13 -0
- package/dist/user-event/types/dom-types.d.ts +56 -0
- package/dist/user-event/types/event/behavior/click.d.ts +1 -0
- package/dist/user-event/types/event/behavior/cut.d.ts +1 -0
- package/dist/user-event/types/event/behavior/index.d.ts +8 -0
- package/dist/user-event/types/event/behavior/keydown.d.ts +1 -0
- package/dist/user-event/types/event/behavior/keypress.d.ts +1 -0
- package/dist/user-event/types/event/behavior/keyup.d.ts +1 -0
- package/dist/user-event/types/event/behavior/paste.d.ts +1 -0
- package/dist/user-event/types/event/behavior/registry.d.ts +9 -0
- package/dist/user-event/types/event/createEvent.d.ts +8 -0
- package/dist/user-event/types/event/dispatchEvent.d.ts +6 -0
- package/dist/user-event/types/event/eventMap.d.ts +265 -0
- package/dist/user-event/types/event/focus.d.ts +6 -0
- package/dist/user-event/types/event/index.d.ts +7 -0
- package/dist/user-event/types/event/input.d.ts +3 -0
- package/dist/user-event/types/event/radio.d.ts +5 -0
- package/dist/user-event/types/event/selection/getInputRange.d.ts +6 -0
- package/dist/user-event/types/event/selection/getTargetTypeAndSelection.d.ts +11 -0
- package/dist/user-event/types/event/selection/index.d.ts +15 -0
- package/dist/user-event/types/event/selection/modifySelection.d.ts +9 -0
- package/dist/user-event/types/event/selection/modifySelectionPerMouse.d.ts +8 -0
- package/dist/user-event/types/event/selection/moveSelection.d.ts +5 -0
- package/dist/user-event/types/event/selection/resolveCaretPosition.d.ts +9 -0
- package/dist/user-event/types/event/selection/selectAll.d.ts +6 -0
- package/dist/user-event/types/event/selection/setSelection.d.ts +11 -0
- package/dist/user-event/types/event/selection/setSelectionPerMouse.d.ts +9 -0
- package/dist/user-event/types/event/selection/setSelectionRange.d.ts +7 -0
- package/dist/user-event/types/event/selection/updateSelectionOnFocus.d.ts +6 -0
- package/dist/user-event/types/event/types.d.ts +21 -0
- package/dist/user-event/types/event/wrapEvent.d.ts +2 -0
- package/dist/user-event/types/index.d.ts +6 -0
- package/dist/user-event/types/keyboard/index.d.ts +3 -0
- package/dist/user-event/types/keyboard/keyMap.d.ts +5 -0
- package/dist/user-event/types/keyboard/parseKeyDef.d.ts +17 -0
- package/dist/user-event/types/options.d.ts +121 -0
- package/dist/user-event/types/pointer/index.d.ts +29 -0
- package/dist/user-event/types/pointer/keyMap.d.ts +2 -0
- package/dist/user-event/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/user-event/types/setup/api.d.ts +23 -0
- package/dist/user-event/types/setup/directApi.d.ts +25 -0
- package/dist/user-event/types/setup/dtl.d.ts +20 -0
- package/dist/user-event/types/setup/index.d.ts +22 -0
- package/dist/user-event/types/setup/setup.d.ts +45 -0
- package/dist/user-event/types/setup/wrapAsync.d.ts +4 -0
- package/dist/user-event/types/system/index.d.ts +13 -0
- package/dist/user-event/types/system/keyLocation.d.ts +11 -0
- package/dist/user-event/types/system/keyboard.d.ts +46 -0
- package/dist/user-event/types/system/pointer/buttons.d.ts +25 -0
- package/dist/user-event/types/system/pointer/device.d.ts +8 -0
- package/dist/user-event/types/system/pointer/index.d.ts +21 -0
- package/dist/user-event/types/system/pointer/mouse.d.ts +31 -0
- package/dist/user-event/types/system/pointer/pointer.d.ts +32 -0
- package/dist/user-event/types/system/pointer/shared.d.ts +21 -0
- package/dist/user-event/types/utility/clear.d.ts +3 -0
- package/dist/user-event/types/utility/index.d.ts +4 -0
- package/dist/user-event/types/utility/selectOptions.d.ts +4 -0
- package/dist/user-event/types/utility/type.d.ts +10 -0
- package/dist/user-event/types/utility/upload.d.ts +6 -0
- package/dist/user-event/types/utils/click/isClickableInput.d.ts +17 -0
- package/dist/user-event/types/utils/dataTransfer/Blob.d.ts +4 -0
- package/dist/user-event/types/utils/dataTransfer/Clipboard.d.ts +12 -0
- package/dist/user-event/types/utils/dataTransfer/DataTransfer.d.ts +3 -0
- package/dist/user-event/types/utils/dataTransfer/FileList.d.ts +2 -0
- package/dist/user-event/types/utils/edit/isContentEditable.d.ts +8 -0
- package/dist/user-event/types/utils/edit/isEditable.d.ts +26 -0
- package/dist/user-event/types/utils/edit/maxLength.d.ts +16 -0
- package/dist/user-event/types/utils/edit/setFiles.d.ts +11 -0
- package/dist/user-event/types/utils/edit/timeValue.d.ts +5 -0
- package/dist/user-event/types/utils/focus/cursor.d.ts +5 -0
- package/dist/user-event/types/utils/focus/getActiveElement.d.ts +3 -0
- package/dist/user-event/types/utils/focus/getTabDestination.d.ts +2 -0
- package/dist/user-event/types/utils/focus/isFocusable.d.ts +2 -0
- package/dist/user-event/types/utils/focus/selection.d.ts +9 -0
- package/dist/user-event/types/utils/focus/selector.d.ts +1 -0
- package/dist/user-event/types/utils/index.d.ts +29 -0
- package/dist/user-event/types/utils/keyDef/readNextDescriptor.d.ts +21 -0
- package/dist/user-event/types/utils/misc/cloneEvent.d.ts +2 -0
- package/dist/user-event/types/utils/misc/findClosest.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getDocumentFromNode.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getTreeDiff.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getWindow.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isDescendantOrSelf.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isDisabled.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isElementType.d.ts +6 -0
- package/dist/user-event/types/utils/misc/isVisible.d.ts +2 -0
- package/dist/user-event/types/utils/misc/level.d.ts +9 -0
- package/dist/user-event/types/utils/misc/wait.d.ts +6 -0
- package/dist/user-event/types/utils/pointer/cssPointerEvents.d.ts +4 -0
- package/dist/vitest-environment/failure-snapshot.js +42 -0
- package/dist/vitest-environment/index.js +185 -0
- package/dist/vitest-environment/plugin.js +90 -0
- package/dist/vitest-environment/types/failure-snapshot.d.ts +1 -0
- package/dist/vitest-environment/types/index.d.ts +29 -0
- package/dist/vitest-environment/types/plugin.d.ts +33 -0
- package/jest-preset.cjs +17 -0
- package/package.json +177 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
import type { Element } from "@ctrl/dom";
|
|
3
|
+
import type { GetComputedStyle } from "./accname.js";
|
|
4
|
+
/**
|
|
5
|
+
* Subtree exclusion for one element: `element.hidden === true` (HTMLElement only),
|
|
6
|
+
* `aria-hidden="true"`, or computed `display: none`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSubtreeInaccessibleImpl(impl: NodeImpl): boolean;
|
|
9
|
+
/** Testing Library's `isInaccessible(element)` with the default subtree check. */
|
|
10
|
+
export declare function isInaccessibleImpl(impl: NodeImpl): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Testing Library's `isInaccessible(element, { isSubtreeInaccessible: cachedIsSubtreeInaccessible })`
|
|
13
|
+
* while the window's `getComputedStyle` is user-replaced (`getComputedStyleOverride`): every
|
|
14
|
+
* style read goes through `gcs` exactly where role-helpers.js calls
|
|
15
|
+
* `window.getComputedStyle(element)` — `visibility` of the element, then `display` per
|
|
16
|
+
* ancestor. `memo` plays upstream's per-query `subtreeIsInaccessibleCache` (pass null for a
|
|
17
|
+
* one-off call). Nothing is cached on the nodes: the replacement's answers are not versioned.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isInaccessibleWithStyle(impl: NodeImpl, gcs: GetComputedStyle, memo: Map<NodeImpl, boolean> | null): boolean;
|
|
20
|
+
export interface IsSubtreeInaccessibleOptions {
|
|
21
|
+
getComputedStyle?: GetComputedStyle | null;
|
|
22
|
+
}
|
|
23
|
+
export interface IsInaccessibleOptions {
|
|
24
|
+
getComputedStyle?: GetComputedStyle | null;
|
|
25
|
+
/** Can be used to return cached results from previous isSubtreeInaccessible calls. */
|
|
26
|
+
isSubtreeInaccessible?: (element: Element) => boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @returns `true` if every child of the element is inaccessible
|
|
30
|
+
* https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
|
|
31
|
+
*/
|
|
32
|
+
export declare function isSubtreeInaccessible(element: Element, options?: IsSubtreeInaccessibleOptions): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Partial implementation of https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion which should
|
|
35
|
+
* only be used for elements with a non-presentational role. Implements aria-hidden
|
|
36
|
+
* semantics (parent overrides child); ignores "Children Presentational: True".
|
|
37
|
+
*/
|
|
38
|
+
export declare function isInaccessible(element: Element, options?: IsInaccessibleOptions): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Element, Node } from "@ctrl/dom";
|
|
2
|
+
import { type ComputeTextAlternativeOptions } from "./accname.js";
|
|
3
|
+
import { isInaccessible, isSubtreeInaccessible } from "./hidden.js";
|
|
4
|
+
export type { ComputeTextAlternativeOptions, GetComputedStyle, StyleLike } from "./accname.js";
|
|
5
|
+
export type { IsInaccessibleOptions, IsSubtreeInaccessibleOptions } from "./hidden.js";
|
|
6
|
+
export { isInaccessible, isSubtreeInaccessible } from "./hidden.js";
|
|
7
|
+
export { getRoles, prettyRoles, type PrettyRolesOptions } from "./roles-list.js";
|
|
8
|
+
export { roles, elementRoles, roleElements, aria, dom, roleSupportsProp, implicitRoleElementNames, superClassRoles, AriaQueryMap, type ARIARoleDefinition, type ARIARoleRelationConcept, } from "./data/aria-query.js";
|
|
9
|
+
/** https://w3c.github.io/accname/#mapping_additional_nd_name */
|
|
10
|
+
export declare function computeAccessibleName(root: Element, options?: ComputeTextAlternativeOptions): string;
|
|
11
|
+
/** https://w3c.github.io/accname/#mapping_additional_nd_description */
|
|
12
|
+
export declare function computeAccessibleDescription(root: Element, options?: ComputeTextAlternativeOptions): string;
|
|
13
|
+
/** dom-accessibility-api `getRole`: explicit role (first token) or the html-aria implicit role, or null. */
|
|
14
|
+
export declare function getRole(element: Element): string | null;
|
|
15
|
+
/** dom-accessibility-api@0.6 `isDisabled`. */
|
|
16
|
+
export declare function isDisabled(element: Element): boolean;
|
|
17
|
+
/** dom-accessibility-api@0.6.3 behavior (aria-description, role="none" ≡ presentation), as used by jest-dom@7. */
|
|
18
|
+
export declare const daa06: {
|
|
19
|
+
computeAccessibleName(root: Element, options?: ComputeTextAlternativeOptions): string;
|
|
20
|
+
computeAccessibleDescription(root: Element, options?: ComputeTextAlternativeOptions): string;
|
|
21
|
+
getRole(element: Element): string | null;
|
|
22
|
+
isDisabled: typeof isDisabled;
|
|
23
|
+
isInaccessible: typeof isInaccessible;
|
|
24
|
+
isSubtreeInaccessible: typeof isSubtreeInaccessible;
|
|
25
|
+
};
|
|
26
|
+
/** Testing Library's `getImplicitAriaRoles(element)` (aria-query@5.3.0 elementRoles semantics). */
|
|
27
|
+
export declare function getImplicitAriaRoles(element: Element | Node): string[];
|
|
28
|
+
/** The implicit role Testing Library computes (`getImplicitAriaRoles(el)[0]`), or null. */
|
|
29
|
+
export declare function getImplicitRole(element: Element | Node): string | null;
|
|
30
|
+
/** jest-dom@7's `getImplicitAriaRoles` variant (used by `toHaveRole`). */
|
|
31
|
+
export declare function getImplicitAriaRolesJestDom(element: Element | Node): string[];
|
|
32
|
+
export declare function computeAriaSelected(element: Element): boolean | undefined;
|
|
33
|
+
export declare function computeAriaBusy(element: Element): boolean;
|
|
34
|
+
export declare function computeAriaChecked(element: Element): boolean | undefined;
|
|
35
|
+
export declare function computeAriaPressed(element: Element): boolean | undefined;
|
|
36
|
+
export declare function computeAriaCurrent(element: Element): boolean | string;
|
|
37
|
+
export declare function computeAriaExpanded(element: Element): boolean | undefined;
|
|
38
|
+
export declare function computeHeadingLevel(element: Element): number | undefined;
|
|
39
|
+
export declare function computeAriaValueNow(element: Element): number | undefined;
|
|
40
|
+
export declare function computeAriaValueMax(element: Element): number | undefined;
|
|
41
|
+
export declare function computeAriaValueMin(element: Element): number | undefined;
|
|
42
|
+
export declare function computeAriaValueText(element: Element): string | undefined;
|
|
43
|
+
/** Tri-state `aria-checked` / checkedness: true, false, "mixed" or undefined. */
|
|
44
|
+
export declare function ariaCheckedState(element: Element): boolean | "mixed" | undefined;
|
|
45
|
+
/** Tri-state `aria-pressed`: true, false, "mixed" or undefined. */
|
|
46
|
+
export declare function ariaPressedState(element: Element): boolean | "mixed" | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { implicitRole, implicitRoleJestDom, getImplicitRoles, tlRole, daaGetRole, daaExplicitRole, daaImplicitRole, anyTag, type Flavor, } from "./role.js";
|
|
2
|
+
export { computeAccessibleNameImpl, computeAccessibleDescriptionImpl, computeTextAlternativeImpl, withStyleOverride, } from "./accname.js";
|
|
3
|
+
export { isInaccessibleImpl, isSubtreeInaccessibleImpl, isInaccessibleWithStyle } from "./hidden.js";
|
|
4
|
+
export { getRolesImpl } from "./roles-list.js";
|
|
5
|
+
export { computeAriaSelected, computeAriaBusy, computeAriaChecked, computeAriaPressed, computeAriaCurrent, computeAriaExpanded, computeHeadingLevel, computeAriaValueNow, computeAriaValueMax, computeAriaValueMin, computeAriaValueText, ariaCheckedState, ariaPressedState, isDisabledImpl, } from "./states.js";
|
|
6
|
+
export { labelsOf, inputType, isLabelable } from "./forms.js";
|
|
7
|
+
export { isDisplayNone, isVisibilityHidden, isDisplayInline } from "./style.js";
|
|
8
|
+
export { implOf, queryIdRefs } from "./tree.js";
|
|
9
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
10
|
+
/**
|
|
11
|
+
* Testing Library's role filter for one element: with a `role` attribute, its first " "-token
|
|
12
|
+
* (or any non-empty token with `queryFallbacks`) must equal `role`; otherwise the implicit
|
|
13
|
+
* role must.
|
|
14
|
+
*/
|
|
15
|
+
export declare function tlRoleMatches(impl: NodeImpl, role: string, queryFallbacks: boolean): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
/** Tag id by local name for any namespace (type selectors / `localName` checks are namespace-agnostic). */
|
|
3
|
+
export declare function anyTag(impl: NodeImpl): number;
|
|
4
|
+
/**
|
|
5
|
+
* The single implicit role Testing Library 10.4 computes for an element, or "" for none
|
|
6
|
+
* (`getImplicitAriaRoles(el)[0] ?? ""`). Every aria-query@5.3.0 element entry maps to
|
|
7
|
+
* exactly one role, so the list form always has at most one element.
|
|
8
|
+
*/
|
|
9
|
+
export declare function implicitRole(impl: NodeImpl): string;
|
|
10
|
+
/** jest-dom@7's `getImplicitAriaRoles` variant (see module comment). */
|
|
11
|
+
export declare function implicitRoleJestDom(impl: NodeImpl): string;
|
|
12
|
+
/** Testing Library's `getImplicitAriaRoles(el)`: a fresh array of zero or one role. */
|
|
13
|
+
export declare function getImplicitRoles(impl: NodeImpl): string[];
|
|
14
|
+
/**
|
|
15
|
+
* The role Testing Library matches `*ByRole` against without `queryFallbacks`: the first
|
|
16
|
+
* " "-separated token of the role attribute when present (possibly ""), else the implicit
|
|
17
|
+
* role ("" for none).
|
|
18
|
+
*/
|
|
19
|
+
export declare function tlRole(impl: NodeImpl): string;
|
|
20
|
+
/** dom-accessibility-api flavor: 5 = 0.5.16 (Testing Library 10.4), 6 = 0.6.3 (jest-dom 7). */
|
|
21
|
+
export type Flavor = 5 | 6;
|
|
22
|
+
/** dom-accessibility-api getExplicitRole: first " "-token of the trimmed role attribute, null when empty. */
|
|
23
|
+
export declare function daaExplicitRole(impl: NodeImpl): string | null;
|
|
24
|
+
/** dom-accessibility-api getImplicitRole. */
|
|
25
|
+
export declare function daaImplicitRole(impl: NodeImpl, flavor: Flavor): string | null;
|
|
26
|
+
/** dom-accessibility-api `getRole(element)`. */
|
|
27
|
+
export declare function daaGetRole(impl: NodeImpl, flavor: Flavor): string | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
import type { Element } from "@ctrl/dom";
|
|
3
|
+
/** Role → elements (tree order), keyed in order of first appearance. Implicit role "" elements are skipped. */
|
|
4
|
+
export declare function getRolesImpl(container: NodeImpl, hidden: boolean): Map<string, NodeImpl[]>;
|
|
5
|
+
/** Testing Library's `getRoles(container, { hidden })`. */
|
|
6
|
+
export declare function getRoles(container: Element, options?: {
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
}): Record<string, Element[]>;
|
|
9
|
+
export interface PrettyRolesOptions {
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
includeDescription?: boolean;
|
|
12
|
+
computedStyleSupportsPseudoElements?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Testing Library's `prettyRoles(dom, { hidden, includeDescription })`. `prettyDOM` formats
|
|
16
|
+
* `el.cloneNode(false)` (it lives in @ctrl/dom/testing-library, which passes its own).
|
|
17
|
+
*/
|
|
18
|
+
export declare function prettyRoles(dom: Element, options: PrettyRolesOptions, prettyDOM: (node: Element) => string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
/** false/true if (not)selected, undefined if not selectable. `<option>` uses its selectedness. */
|
|
3
|
+
export declare function computeAriaSelected(impl: NodeImpl): boolean | undefined;
|
|
4
|
+
export declare function computeAriaBusy(impl: NodeImpl): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* false/true if (not)checked, undefined if not checkable. HTML `<input>` elements of every
|
|
7
|
+
* type use their checkedness (undefined while indeterminate); others read `aria-checked`
|
|
8
|
+
* (`"mixed"` → undefined, as in Testing Library).
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeAriaChecked(impl: NodeImpl): boolean | undefined;
|
|
11
|
+
/** Tri-state checked: true / false / "mixed" / undefined (not checkable). */
|
|
12
|
+
export declare function ariaCheckedState(impl: NodeImpl): boolean | "mixed" | undefined;
|
|
13
|
+
export declare function computeAriaPressed(impl: NodeImpl): boolean | undefined;
|
|
14
|
+
/** Tri-state pressed: true / false / "mixed" / undefined. */
|
|
15
|
+
export declare function ariaPressedState(impl: NodeImpl): boolean | "mixed" | undefined;
|
|
16
|
+
export declare function computeAriaCurrent(impl: NodeImpl): boolean | string;
|
|
17
|
+
export declare function computeAriaExpanded(impl: NodeImpl): boolean | undefined;
|
|
18
|
+
/** Explicit `aria-level` (if truthy as a Number) or the h1–h6 level; undefined otherwise. */
|
|
19
|
+
export declare function computeHeadingLevel(impl: NodeImpl): number | undefined;
|
|
20
|
+
export declare function computeAriaValueNow(impl: NodeImpl): number | undefined;
|
|
21
|
+
export declare function computeAriaValueMax(impl: NodeImpl): number | undefined;
|
|
22
|
+
export declare function computeAriaValueMin(impl: NodeImpl): number | undefined;
|
|
23
|
+
export declare function computeAriaValueText(impl: NodeImpl): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* dom-accessibility-api@0.6 `isDisabled`: `disabled` on button, fieldset, input, optgroup,
|
|
26
|
+
* option, select, textarea (by local name), else `aria-disabled="true"`.
|
|
27
|
+
* https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
|
|
28
|
+
*/
|
|
29
|
+
export declare function isDisabledImpl(impl: NodeImpl): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
/** Computed `display` is `none` (the element itself; `display` is not inherited). */
|
|
3
|
+
export declare function isDisplayNone(impl: NodeImpl): boolean;
|
|
4
|
+
/** Computed `display` is exactly `inline` (accname: inline children are not space-separated). */
|
|
5
|
+
export declare function isDisplayInline(impl: NodeImpl): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Computed `visibility` is exactly `hidden` (inherited). `collapse` does not count: Testing
|
|
8
|
+
* Library and dom-accessibility-api compare against "hidden" only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isVisibilityHidden(impl: NodeImpl): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Textual `content` of `::before` / `::after` as dom-accessibility-api extracts it from
|
|
13
|
+
* `getComputedStyle(el, pseudo).getPropertyValue("content")`: a value that starts and ends
|
|
14
|
+
* with a quote, with the outer quotes sliced off; anything else is "".
|
|
15
|
+
*/
|
|
16
|
+
export declare function pseudoText(impl: NodeImpl, pseudo: "::before" | "::after"): string;
|
|
17
|
+
/** Whether author style sheets (`<style>`, `<link rel=stylesheet>`) are applied. */
|
|
18
|
+
export declare const AUTHOR_STYLES_SUPPORTED: boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type NodeImpl } from "@ctrl/dom/internal";
|
|
2
|
+
import type { Element, Node } from "@ctrl/dom";
|
|
3
|
+
/** The NodeImpl behind a public wrapper. */
|
|
4
|
+
export declare function implOf(node: Node | Element): NodeImpl;
|
|
5
|
+
/**
|
|
6
|
+
* `root.getElementById(id)` for a Document or DocumentFragment/ShadowRoot root.
|
|
7
|
+
* https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
|
8
|
+
*/
|
|
9
|
+
export declare function elementByIdInRoot(root: NodeImpl, id: string): NodeImpl | null;
|
|
10
|
+
/**
|
|
11
|
+
* dom-accessibility-api's `queryIdRefs(node, attributeName)`: split the attribute on " "
|
|
12
|
+
* and resolve each token with `node.getRootNode().getElementById(token)`.
|
|
13
|
+
* https://w3c.github.io/aria/#valuetype_idref_list
|
|
14
|
+
*
|
|
15
|
+
* Deviation: when the root is a detached element (which has no getElementById, so
|
|
16
|
+
* dom-accessibility-api throws a TypeError), this returns no elements.
|
|
17
|
+
*/
|
|
18
|
+
export declare function queryIdRefs(impl: NodeImpl, value: string | null, out: NodeImpl[]): NodeImpl[];
|
|
19
|
+
/** https://dom.spec.whatwg.org/#dom-node-textcontent for an element (descendant text, tree order). */
|
|
20
|
+
export declare function textContent(impl: NodeImpl): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Generated by scripts/release.ts (writeBridges): the running ctrl-dom environment's DOM, else a fresh load.
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const dom = globalThis[Symbol.for("ctrl-dom.dom.modules")]?.dom ?? createRequire(import.meta.url)("../dom/index.js");
|
|
4
|
+
export const { AbstractRange, AnimationEvent, Attr, Audio, BeforeUnloadEvent, CDATASection, CSS, CSSConditionRule, CSSContainerRule, CSSFontFaceRule, CSSGroupingRule, CSSImportRule, CSSKeyframeRule, CSSKeyframesRule, CSSLayerBlockRule, CSSLayerStatementRule, CSSMediaRule, CSSNamespaceRule, CSSNestedDeclarations, CSSPageRule, CSSPropertyRule, CSSRule, CSSRuleList, CSSScopeRule, CSSStartingStyleRule, CSSStyleDeclaration, CSSStyleRule, CSSStyleSheet, CSSSupportsRule, CharacterData, Clipboard, ClipboardEvent, ClipboardItem, CloseEvent, CommandEvent, Comment, CompositionEvent, CustomElementRegistry, CustomEvent, CustomStateSet, DOMImplementation, DOMMatrix, DOMMatrixReadOnly, DOMParser, DOMPoint, DOMPointReadOnly, DOMRect, DOMRectList, DOMRectReadOnly, DOMStringMap, DOMTokenList, DataTransfer, DataTransferItem, DataTransferItemList, Document, DocumentFragment, DocumentType, DragEvent, Element, ElementInternals, ErrorEvent, Event, EventTarget, FileList, FileReader, FocusEvent, FormData, FormDataEvent, HTMLAnchorElement, HTMLAreaElement, HTMLAudioElement, HTMLBRElement, HTMLBaseElement, HTMLBodyElement, HTMLButtonElement, HTMLCanvasElement, HTMLCollection, HTMLDListElement, HTMLDataElement, HTMLDataListElement, HTMLDetailsElement, HTMLDialogElement, HTMLDirectoryElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLEmbedElement, HTMLFieldSetElement, HTMLFontElement, HTMLFormControlsCollection, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement, HTMLHRElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLLIElement, HTMLLabelElement, HTMLLegendElement, HTMLLinkElement, HTMLMapElement, HTMLMarqueeElement, HTMLMediaElement, HTMLMenuElement, HTMLMetaElement, HTMLMeterElement, HTMLModElement, HTMLOListElement, HTMLObjectElement, HTMLOptGroupElement, HTMLOptionElement, HTMLOptionsCollection, HTMLOutputElement, HTMLParagraphElement, HTMLParamElement, HTMLPictureElement, HTMLPreElement, HTMLProgressElement, HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLSlotElement, HTMLSourceElement, HTMLSpanElement, HTMLStyleElement, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement, HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement, HTMLTemplateElement, HTMLTextAreaElement, HTMLTimeElement, HTMLTitleElement, HTMLTrackElement, HTMLUListElement, HTMLUnknownElement, HTMLVideoElement, HashChangeEvent, History, Image, InputEvent, IntersectionObserver, KeyboardEvent, Location, MathMLElement, MediaError, MediaList, MediaQueryList, MediaQueryListEvent, MessageEvent, MouseEvent, MutationObserver, MutationRecord, NamedNodeMap, Navigator, Node, NodeFilter, NodeIterator, NodeList, Option, PageTransitionEvent, PointerEvent, PopStateEvent, ProcessingInstruction, ProgressEvent, PromiseRejectionEvent, RadioNodeList, Range, ResizeObserver, SVGAElement, SVGAnimatedString, SVGCircleElement, SVGClipPathElement, SVGDefsElement, SVGDescElement, SVGElement, SVGEllipseElement, SVGFilterElement, SVGForeignObjectElement, SVGGElement, SVGGeometryElement, SVGGradientElement, SVGGraphicsElement, SVGImageElement, SVGLineElement, SVGLinearGradientElement, SVGMarkerElement, SVGMaskElement, SVGMetadataElement, SVGPathElement, SVGPatternElement, SVGPolygonElement, SVGPolylineElement, SVGRadialGradientElement, SVGRectElement, SVGSVGElement, SVGScriptElement, SVGStopElement, SVGStyleElement, SVGSwitchElement, SVGSymbolElement, SVGTSpanElement, SVGTextContentElement, SVGTextElement, SVGTextPathElement, SVGTextPositioningElement, SVGTitleElement, SVGUseElement, SVGViewElement, Screen, Selection, ShadowRoot, StaticRange, Storage, StorageEvent, StyleSheet, StyleSheetList, SubmitEvent, Text, TextEvent, TimeRanges, ToggleEvent, Touch, TouchEvent, TouchList, TransitionEvent, TreeWalker, UIEvent, ValidityState, VisualViewport, WheelEvent, Window, XMLDocument, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, XMLSerializer, createWindow, currentDocument, currentWindow, currentWindowOrNull, getComputedStyle, installGlobals, setCurrentWindow } = dom;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Generated by scripts/release.ts (writeBridges): the running ctrl-dom environment's DOM, else a fresh load.
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const dom = globalThis[Symbol.for("ctrl-dom.dom.modules")]?.internal ?? createRequire(import.meta.url)("../dom/internal.js");
|
|
4
|
+
export const { $_proto__, $aboutBase, $active, $assocGen, $attr, $attributes, $availableToElementInternals, $badInput, $baseFor, $baseOverride, $baseURL, $baseVersion, $block, $byCtor, $byName, $cache, $callback, $checked, $checkedSet, $childNodes, $childWindows, $children, $classList, $clipboard, $clonable, $closed, $coll, $compiled, $compiledFor, $condition, $constructed, $constructingEntryList, $contentType, $controlsCache, $controlsDoc, $controlsVersion, $cookieJar, $cookies, $css, $current, $customElements, $customValidity, $cx, $data, $dataset, $declarative, $defaultNamespace, $defaultValueOverride, $delegatesFocus, $derived, $devicePixelRatio, $dirtiness, $dirtyChecked, $dirtyValue, $disabled, $disallowModification, $doc, $dropEffect, $ec, $effectAllowed, $el, $elements, $entries, $eo, $error, $file, $files, $fill, $filter, $firingSubmissionEvents, $focused, $form, $forms, $frameCallbacks, $frameElement, $frameId, $frameTask, $frameTime, $generation, $globalObject, $hasTransients, $height, $history, $home, $host, $href, $id, $idleCallbacks, $idleId, $ids, $impl, $implementation, $indeterminate, $index, $indexed, $inflight, $info, $innerHeight, $innerWidth, $is2D, $isHTML, $items, $keyText, $kind, $labels, $layerName, $list, $listeners, $localStorage, $location, $lockedForReset, $m, $matches, $media, $mediaQueryLists, $mode, $name, $names, $namespaces, $navigator, $nodes, $onchange, $options, $owner, $ownerNode, $ownerRule, $parent, $parentRule, $parentWindow, $pastNames, $pointerBeforeReference, $preApplied, $preChecked, $preCheckedRadio, $preIndeterminate, $prefix, $prelude, $presentationStyle, $pseudo, $queries, $ranges, $rawValue, $readonly, $readyState, $record, $records, $rects, $reference, $result, $root, $rules, $running, $runningFrame, $sc, $screen, $scrollRestoration, $scrollX, $scrollY, $selDir, $selEnd, $selSet, $selStart, $selectedOptions, $selectedness, $selection, $selector, $serializable, $sessionStorage, $settled, $shadowRoot, $shed, $sheet, $sheets, $slotAssignment, $so, $states, $style, $styleVersion, $supportsText, $systemId, $target, $targets, $tasks, $timers, $title, $type, $types, $uiValue, $updating, $updatingSelectedContent, $uri, $url, $userActivation, $userEdited, $userValidity, $validity, $value, $version, $visualViewport, $w, $whatToShow, $whenDefined, $width, $window, $writeBuffer, $x, $xhr, $y, $z, ATTRIBUTE_NODE, AttrRecord, CDATA_SECTION_NODE, COMMENT_NODE, COMPAT, COMPAT_PROFILES, DEFAULT_COMPAT, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, DeclBlock, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, EventState, FAILURE_CHANNEL, F_ADOPT_HOOK, F_ATTR_HOOK, F_CE_CUSTOM, F_CHILDREN_HOOK, F_CHILD_LIST, F_CONNECTED, F_CONNECT_HOOK, F_CUSTOM, F_FACE, F_HAS_SHADOW, F_HAS_STYLE_ATTR, F_HTML, F_MO_REGISTERED, F_SHADOW_ROOT, GLOBAL_EVENT_HANDLER_EVENTS, HTMLCollection, HTML_NS, INPUT_TYPE_NAMES, MATHML_NS, NOTATION_NODE, NodeCache, NodeImpl, NodeList, PROCESSING_INSTRUCTION_NODE, SPAN_CHANNEL, SVG_NS, T, TEXT_NODE, VirtualClock, VirtualTimeout, WINDOW_EVENT_HANDLER_EVENTS, XLINK_NS, XMLNS_NS, XML_NS, activeObservers, adoptedStyleSheetsOf, asciiLowercase, assignManually, assignedElements, assignedNodes, assignedSlot, attachShadowRoot, attr, attrAssociatedElement, attrAssociatedElements, attrNode, captureInterfaceBaseline, childAt, classTokens, clearUIValue, clockNow, clockStats, closest, compareBoundaryPoints, compatExposes, computedDisplay, computedValue, computedVisibility, constructEntryList, controlValue, createEvent, createFileList, createLinkSheet, currentStyleVersion, defaultButton, deferredCompatMembers, derivedCache, describeCall, describeNode, dispatch, dispatchTrusted, ensureCollectionIndexGetters, ensureIndexGetters, evaluateMediaQueryList, faceState, findFlattenedSlottables, findSlot, fireAnEvent, fireSyntheticPointerEvent, firstElementChild, formOwner, getAttribute, getComputedStyle, getComputedStyleOverride, getCurrentEvent, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, getEventHandler, getUISelection, getUIValue, guardInterfaceDefinitions, hasAttr, hasAuthorStyles, hasExplicitAttrElements, hasListeners, hasReadonlyAttribute, hasUIValue, hiddenGlobals, implicitSubmission, indexGetterTable, indexOf, inputChecked, inputIndeterminate, inputType, inputTypeFromAttr, inspectNode, installClock, installEventHandlers, isActuallyDisabled, isAsciiWhitespace, isAutofilled, isChecked, isDefault, isDisabled, isDisplayNone, isDisplayNoneInclusive, isEditableControl, isEnabled, isFACE, isInRange, isInclusiveAncestor, isIndeterminate, isInvalid, isLabelable, isListed, isMutable, isNumericType, isOptional, isOutOfRange, isPlaceholderShown, isReadOnly, isReadWrite, isRequired, isResettable, isSubmitButton, isSubmittable, isTextControl, isTextualType, isValid, isValidDoctypeName, isValidElementLocalName, isValidNamespacePrefix, isVisibilityHidden, labeledControl, labelsFor, lastElementChild, listOfOptions, matchMediaText, matches, mediaEnvironment, nextElementInTree, nextElementSibling, nextInTree, nextSkippingChildren, nodeCache, nodeGetTheParent, nodeLength, notifyMutationObservers, optionSelected, parseDeclBlock, parseFragment, parseMediaQueryList, peekDerivedCache, pointerEvents, pointerEventsNone, previousElementSibling, previousInTree, pseudoContent, querySelector, querySelectorAll, quote, registerOwnerSheet, removeAllEventListeners, removeAttribute, removeOwnerSheet, replaceData, reportException, resolveCompat, restoreInterfaces, retarget, serializeChildren, serializeNode, setAdoptedStyleSheets, setAssignedSlotLookup, setAttribute, setCheckedFromUI, setComputedColorMode, setEventHandler, setFailureSnapshot, setFilesFromUI, setNodeDescriber, setNotImplementedHandler, setOptionSelectedFromUI, setTrusted, setUISelection, setUIValue, setUncaughtExceptionHandler, skipIdleTime, spanChannel, splitOnAsciiWhitespace, splitText, styleElementRemoved, styleElementSheet, styleElementUpdated, styleSheetsOf, subscribeTestFailures, supportsSelection, supportsSelectionType, tagId, tagName, tracePromise, traceSync, tracing, trackGlobalTimers, treeRoot, uaDisplay, unregisterOwnerSheet, validateAndExtract, valueMode, virtualDate, virtualPerformance, windowHooks, windowInterfaces, withNamedProperties } = dom;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { relative, sep } from "node:path";
|
|
2
|
+
import { stripVTControlCharacters } from "node:util";
|
|
3
|
+
|
|
4
|
+
// src/report.ts
|
|
5
|
+
/** Strip ANSI escape sequences. */
|
|
6
|
+
function stripAnsi(text) {
|
|
7
|
+
return stripVTControlCharacters(String(text));
|
|
8
|
+
}
|
|
9
|
+
const FRAME = /^\s*at (?:(.*?) \()?(?:file:\/\/)?(\/[^():]+|[A-Za-z]:\\[^():]+):(\d+):(\d+)\)?\s*$/;
|
|
10
|
+
/**
|
|
11
|
+
* `file:line:column`, relative to `root`, of the first stack frame in `testFile`, else of the first
|
|
12
|
+
* frame outside node_modules and Node internals.
|
|
13
|
+
*/
|
|
14
|
+
function firstProjectFrame(stack, root, testFile) {
|
|
15
|
+
let fallback = null;
|
|
16
|
+
for (const line of String(stack ?? "").split("\n")) {
|
|
17
|
+
const m = FRAME.exec(line);
|
|
18
|
+
if (m === null) continue;
|
|
19
|
+
const file = m[2];
|
|
20
|
+
if (file.includes(`${sep}node_modules${sep}`) || file.includes("/node_modules/")) continue;
|
|
21
|
+
const at = `${relative(root, file) || file}:${m[3]}:${m[4]}`;
|
|
22
|
+
if (testFile === void 0 || file === testFile) return at;
|
|
23
|
+
fallback ??= at;
|
|
24
|
+
}
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
/** An error message without its stack frames (` at …` lines). */
|
|
28
|
+
function messageWithoutFrames(text) {
|
|
29
|
+
const lines = stripAnsi(text).split("\n");
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const line of lines) if (!/^\s*at .+(:\d+:\d+\)?|\(<anonymous>\)|native\))\s*$/.test(line)) out.push(line);
|
|
32
|
+
while (out.length > 0 && out[out.length - 1].trim() === "") out.pop();
|
|
33
|
+
return out.join("\n");
|
|
34
|
+
}
|
|
35
|
+
function indent(text, prefix = " ") {
|
|
36
|
+
return text.split("\n").map((line) => line === "" ? line : prefix + line).join("\n");
|
|
37
|
+
}
|
|
38
|
+
/** Keep at most `max` lines, noting how many were cut. */
|
|
39
|
+
function budget(text, max) {
|
|
40
|
+
const lines = text.split("\n");
|
|
41
|
+
if (lines.length <= max) return text;
|
|
42
|
+
return `${lines.slice(0, max).join("\n")}\n… ${lines.length - max} more lines`;
|
|
43
|
+
}
|
|
44
|
+
const CONSOLE_MAX_LINES = Number(process.env.CTRL_DOM_DEBUG_CONSOLE_LINES) > 0 ? Number(process.env.CTRL_DOM_DEBUG_CONSOLE_LINES) : 150;
|
|
45
|
+
const FAILURE_MAX_LINES = 400;
|
|
46
|
+
/** The report. */
|
|
47
|
+
function formatReport(r) {
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const f of r.errors) {
|
|
50
|
+
out.push(`ERROR ${f.name}`, indent(budget(f.message, FAILURE_MAX_LINES)));
|
|
51
|
+
if (f.at) out.push("", ` at ${f.at}`);
|
|
52
|
+
out.push("");
|
|
53
|
+
}
|
|
54
|
+
for (const f of r.failures) {
|
|
55
|
+
out.push(`FAIL ${f.name}`, indent(budget(f.message, FAILURE_MAX_LINES)));
|
|
56
|
+
if (f.at) out.push("", ` at ${f.at}`);
|
|
57
|
+
out.push("");
|
|
58
|
+
}
|
|
59
|
+
if (r.logs.length > 0) {
|
|
60
|
+
let used = 0;
|
|
61
|
+
let cut = 0;
|
|
62
|
+
const parts = [];
|
|
63
|
+
for (const log of r.logs) {
|
|
64
|
+
const content = stripAnsi(log.content).replace(/\n$/, "");
|
|
65
|
+
const lines = content.split("\n").length + 1;
|
|
66
|
+
if (used + lines > CONSOLE_MAX_LINES) {
|
|
67
|
+
cut++;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
used += lines;
|
|
71
|
+
parts.push(`${log.type === "stderr" ? "stderr" : "stdout"} | ${log.name}`, indent(content));
|
|
72
|
+
}
|
|
73
|
+
out.push("Console output:", ...parts);
|
|
74
|
+
if (cut > 0) out.push(`… ${cut} more console messages (CTRL_DOM_DEBUG_CONSOLE_LINES raises the budget)`);
|
|
75
|
+
out.push("");
|
|
76
|
+
}
|
|
77
|
+
const counts = [
|
|
78
|
+
r.failed && `${r.failed} failed`,
|
|
79
|
+
r.passed && `${r.passed} passed`,
|
|
80
|
+
r.skipped && `${r.skipped} skipped`
|
|
81
|
+
].filter(Boolean).join(", ") || "no tests ran";
|
|
82
|
+
out.push(`${counts} · ${r.runner} · ${r.files.join(", ") || "(no test files)"} · ${(r.durationMs / 1e3).toFixed(1)} s`);
|
|
83
|
+
return `${out.join("\n")}\n`;
|
|
84
|
+
}
|
|
85
|
+
/** A hint when failures came without the snapshot a failure should carry in agent mode. */
|
|
86
|
+
function missingSnapshotHint(failures, runner) {
|
|
87
|
+
if (failures.length === 0 || process.env.CTRL_DOM_DEBUG === void 0) return "";
|
|
88
|
+
if (failures.some((f) => f.message.includes("when the test failed"))) return "";
|
|
89
|
+
if (runner === "vitest") return "Note: no failure snapshots. Use ctrlDom() from \"@ctrl/dom/vitest\", or add \"@ctrl/dom/vitest-environment/failure-snapshot\" to test.setupFiles (the ctrl-dom environment is required).\n";
|
|
90
|
+
return "Note: no failure snapshots. They need testEnvironment \"@ctrl/dom-jest-environment\" or preset \"@ctrl/dom\".\n";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { stripAnsi as a, missingSnapshotHint as i, formatReport as n, messageWithoutFrames as r, firstProjectFrame as t };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { parseArgs } from "node:util";
|
|
8
|
+
|
|
9
|
+
// src/ctrl-dom.ts
|
|
10
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const extension = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
12
|
+
const USAGE = `Usage: ctrl-dom debug <test file>... [options] [-- <runner args>]
|
|
13
|
+
|
|
14
|
+
Runs the test file(s) with Vitest or Jest (whichever the project uses) and CTRL_DOM_DEBUG=aria,
|
|
15
|
+
and prints a compact report: each failure with its message (closest matches for failed queries,
|
|
16
|
+
the accessibility snapshot of the page when the test failed), console output, and a summary.
|
|
17
|
+
Exits with the test run's status.
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
-t, --test-name <pattern> only run tests whose name matches (Vitest/Jest -t)
|
|
21
|
+
--runner <vitest|jest> skip detection
|
|
22
|
+
--config <file> the runner's config file
|
|
23
|
+
--format <aria|compact> CTRL_DOM_DEBUG value (default aria)
|
|
24
|
+
--lines <n> CTRL_DOM_DEBUG_LINES: line budget for snapshots
|
|
25
|
+
--raw the runner's own output instead of the compact report
|
|
26
|
+
-h, --help this help
|
|
27
|
+
|
|
28
|
+
Example:
|
|
29
|
+
npx ctrl-dom debug src/Checkout.test.tsx -t "submits the form"
|
|
30
|
+
`;
|
|
31
|
+
function fail(message) {
|
|
32
|
+
process.stderr.write(`ctrl-dom: ${message}\n`);
|
|
33
|
+
process.exit(2);
|
|
34
|
+
}
|
|
35
|
+
function readJson(path) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The nearest directory at or above `from` with a package.json. */
|
|
43
|
+
function projectRoot(from) {
|
|
44
|
+
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
45
|
+
if (existsSync(join(dir, "package.json"))) return dir;
|
|
46
|
+
if (dirname(dir) === dir) return resolve(from);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const CONFIGS = {
|
|
50
|
+
vitest: [
|
|
51
|
+
"vitest.config.ts",
|
|
52
|
+
"vitest.config.mts",
|
|
53
|
+
"vitest.config.js",
|
|
54
|
+
"vitest.config.mjs",
|
|
55
|
+
"vitest.config.cts",
|
|
56
|
+
"vitest.config.cjs",
|
|
57
|
+
"vitest.workspace.ts"
|
|
58
|
+
],
|
|
59
|
+
jest: [
|
|
60
|
+
"jest.config.js",
|
|
61
|
+
"jest.config.cjs",
|
|
62
|
+
"jest.config.mjs",
|
|
63
|
+
"jest.config.ts",
|
|
64
|
+
"jest.config.mts",
|
|
65
|
+
"jest.config.json"
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
/** Vitest or Jest: from --config's name, the test files' imports, config files, then dependencies. */
|
|
69
|
+
function detectRunner(root, files, config) {
|
|
70
|
+
if (config !== void 0) {
|
|
71
|
+
const name = config.split(/[\\/]/).pop();
|
|
72
|
+
if (/^(vitest|vite)\./.test(name)) return "vitest";
|
|
73
|
+
if (name.startsWith("jest.")) return "jest";
|
|
74
|
+
}
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
let source = "";
|
|
77
|
+
try {
|
|
78
|
+
source = readFileSync(resolve(file), "utf8");
|
|
79
|
+
} catch {}
|
|
80
|
+
if (/from\s+["']vitest["']|require\(["']vitest["']\)/.test(source)) return "vitest";
|
|
81
|
+
if (/from\s+["']@jest\/globals["']|require\(["']@jest\/globals["']\)/.test(source)) return "jest";
|
|
82
|
+
}
|
|
83
|
+
const pkg = readJson(join(root, "package.json")) ?? {};
|
|
84
|
+
const hasConfig = (runner) => CONFIGS[runner].some((name) => existsSync(join(root, name))) || runner === "jest" && pkg.jest !== void 0;
|
|
85
|
+
if (hasConfig("vitest") && !hasConfig("jest")) return "vitest";
|
|
86
|
+
if (hasConfig("jest") && !hasConfig("vitest")) return "jest";
|
|
87
|
+
const deps = {
|
|
88
|
+
...pkg.dependencies,
|
|
89
|
+
...pkg.devDependencies
|
|
90
|
+
};
|
|
91
|
+
if (deps.vitest && !deps.jest) return "vitest";
|
|
92
|
+
if (deps.jest && !deps.vitest) return "jest";
|
|
93
|
+
if (hasConfig("vitest") || deps.vitest) return "vitest";
|
|
94
|
+
if ([
|
|
95
|
+
"vite.config.ts",
|
|
96
|
+
"vite.config.js",
|
|
97
|
+
"vite.config.mjs"
|
|
98
|
+
].some((name) => existsSync(join(root, name)))) return "vitest";
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/** The runner's CLI script, resolved from the project (its `bin` entry). */
|
|
102
|
+
function runnerBin(root, runner) {
|
|
103
|
+
const require = createRequire(join(root, "package.json"));
|
|
104
|
+
let pkgPath = "";
|
|
105
|
+
try {
|
|
106
|
+
pkgPath = require.resolve(`${runner}/package.json`);
|
|
107
|
+
} catch {
|
|
108
|
+
fail(`${runner} is not installed in ${root}`);
|
|
109
|
+
}
|
|
110
|
+
const pkg = readJson(pkgPath) ?? {};
|
|
111
|
+
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[runner];
|
|
112
|
+
if (!bin) fail(`cannot find ${runner}'s CLI in ${pkgPath}`);
|
|
113
|
+
return join(dirname(pkgPath), bin);
|
|
114
|
+
}
|
|
115
|
+
const OPTIONS = {
|
|
116
|
+
"test-name": {
|
|
117
|
+
type: "string",
|
|
118
|
+
short: "t"
|
|
119
|
+
},
|
|
120
|
+
runner: { type: "string" },
|
|
121
|
+
config: { type: "string" },
|
|
122
|
+
format: {
|
|
123
|
+
type: "string",
|
|
124
|
+
default: "aria"
|
|
125
|
+
},
|
|
126
|
+
lines: { type: "string" },
|
|
127
|
+
raw: {
|
|
128
|
+
type: "boolean",
|
|
129
|
+
default: false
|
|
130
|
+
},
|
|
131
|
+
help: {
|
|
132
|
+
type: "boolean",
|
|
133
|
+
short: "h",
|
|
134
|
+
default: false
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
function parseOptions(args) {
|
|
138
|
+
try {
|
|
139
|
+
return parseArgs({
|
|
140
|
+
args,
|
|
141
|
+
allowPositionals: true,
|
|
142
|
+
options: OPTIONS
|
|
143
|
+
});
|
|
144
|
+
} catch (error) {
|
|
145
|
+
fail(`${error.message}\n\n${USAGE}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function main(argv) {
|
|
149
|
+
const [command, ...rest] = argv;
|
|
150
|
+
if (command === void 0 || command === "-h" || command === "--help" || command === "help") {
|
|
151
|
+
process.stdout.write(USAGE);
|
|
152
|
+
return command === void 0 ? 2 : 0;
|
|
153
|
+
}
|
|
154
|
+
if (command !== "debug") fail(`unknown command "${command}"\n\n${USAGE}`);
|
|
155
|
+
const dashDash = rest.indexOf("--");
|
|
156
|
+
const own = dashDash < 0 ? rest : rest.slice(0, dashDash);
|
|
157
|
+
const passthrough = dashDash < 0 ? [] : rest.slice(dashDash + 1);
|
|
158
|
+
const { values, positionals: files } = parseOptions(own);
|
|
159
|
+
if (values.help) {
|
|
160
|
+
process.stdout.write(USAGE);
|
|
161
|
+
return 0;
|
|
162
|
+
}
|
|
163
|
+
if (files.length === 0) fail(`no test file given\n\n${USAGE}`);
|
|
164
|
+
if (!["aria", "compact"].includes(values.format)) fail(`--format must be aria or compact`);
|
|
165
|
+
const root = projectRoot(process.cwd());
|
|
166
|
+
const runner = values.runner ?? detectRunner(root, files, values.config);
|
|
167
|
+
if (runner !== "vitest" && runner !== "jest") fail(runner ? `--runner must be vitest or jest` : `cannot tell whether ${root} uses Vitest or Jest: pass --runner`);
|
|
168
|
+
const args = [runnerBin(root, runner)];
|
|
169
|
+
if (runner === "vitest") {
|
|
170
|
+
args.push("run", ...files);
|
|
171
|
+
if (values.config) args.push("--config", values.config);
|
|
172
|
+
if (values["test-name"] !== void 0) args.push("-t", values["test-name"]);
|
|
173
|
+
if (!values.raw) args.push(`--reporter=${join(here, `vitest-reporter${extension}`)}`);
|
|
174
|
+
} else {
|
|
175
|
+
args.push("--runTestsByPath", ...files.map((file) => resolve(file)), "--ci");
|
|
176
|
+
if (values.config) args.push("--config", values.config);
|
|
177
|
+
if (values["test-name"] !== void 0) args.push("-t", values["test-name"]);
|
|
178
|
+
if (!values.raw) args.push(`--reporters=${join(here, `jest-reporter${extension}`)}`);
|
|
179
|
+
}
|
|
180
|
+
args.push(...passthrough);
|
|
181
|
+
const env = {
|
|
182
|
+
...process.env,
|
|
183
|
+
CTRL_DOM_DEBUG: values.format,
|
|
184
|
+
FORCE_COLOR: "0",
|
|
185
|
+
NO_COLOR: "1"
|
|
186
|
+
};
|
|
187
|
+
if (values.lines !== void 0) env.CTRL_DOM_DEBUG_LINES = values.lines;
|
|
188
|
+
process.stdout.write(`ctrl-dom debug: ${runner} ${files.join(" ")}${values["test-name"] !== void 0 ? ` -t ${JSON.stringify(values["test-name"])}` : ""} (CTRL_DOM_DEBUG=${values.format})\n\n`);
|
|
189
|
+
const run = spawnSync(process.execPath, args, {
|
|
190
|
+
cwd: process.cwd(),
|
|
191
|
+
env,
|
|
192
|
+
stdio: "inherit"
|
|
193
|
+
});
|
|
194
|
+
if (run.error) fail(run.error.message);
|
|
195
|
+
return run.status ?? 1;
|
|
196
|
+
}
|
|
197
|
+
if (import.meta.main) process.exitCode = main(process.argv.slice(2));
|
|
198
|
+
|
|
199
|
+
export { detectRunner, main };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { i as missingSnapshotHint, n as formatReport, r as messageWithoutFrames, t as firstProjectFrame } from "./_chunks/report-DdncYfuJ.js";
|
|
2
|
+
import { relative } from "node:path";
|
|
3
|
+
|
|
4
|
+
// src/jest-reporter.ts
|
|
5
|
+
var CtrlDomDebugReporter = class {
|
|
6
|
+
root = process.cwd();
|
|
7
|
+
start = performance.now();
|
|
8
|
+
onRunComplete(_testContexts, results) {
|
|
9
|
+
const failures = [];
|
|
10
|
+
const errors = [];
|
|
11
|
+
const logs = [];
|
|
12
|
+
const files = [];
|
|
13
|
+
for (const file of results.testResults) {
|
|
14
|
+
const name = relative(this.root, file.testFilePath) || file.testFilePath;
|
|
15
|
+
files.push(name);
|
|
16
|
+
if (file.testExecError) {
|
|
17
|
+
const error = file.testExecError;
|
|
18
|
+
errors.push({
|
|
19
|
+
name,
|
|
20
|
+
message: messageWithoutFrames(error.stack ?? error.message ?? String(error)),
|
|
21
|
+
at: firstProjectFrame(error.stack, this.root, file.testFilePath)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
for (const test of file.testResults) {
|
|
25
|
+
if (test.status !== "failed") continue;
|
|
26
|
+
const text = test.failureMessages.join("\n\n");
|
|
27
|
+
failures.push({
|
|
28
|
+
name: test.fullName,
|
|
29
|
+
message: messageWithoutFrames(text),
|
|
30
|
+
at: firstProjectFrame(text, this.root, file.testFilePath)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
for (const entry of file.console ?? []) logs.push({
|
|
34
|
+
name,
|
|
35
|
+
type: entry.type === "error" || entry.type === "warn" ? "stderr" : "stdout",
|
|
36
|
+
content: entry.message
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
process.stdout.write(formatReport({
|
|
40
|
+
runner: "jest",
|
|
41
|
+
root: this.root,
|
|
42
|
+
failures,
|
|
43
|
+
errors,
|
|
44
|
+
logs,
|
|
45
|
+
passed: results.numPassedTests,
|
|
46
|
+
failed: results.numFailedTests,
|
|
47
|
+
skipped: results.numPendingTests + results.numTodoTests,
|
|
48
|
+
files,
|
|
49
|
+
durationMs: performance.now() - this.start
|
|
50
|
+
}));
|
|
51
|
+
process.stdout.write(missingSnapshotHint(failures, "jest"));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { CtrlDomDebugReporter as default };
|