@testing-library/jest-dom
Advanced tools
Comparing version 6.5.0 to 6.6.0
'use strict'; | ||
var matchers = require('./matchers-4fe91ec3.js'); | ||
var matchers = require('./matchers-3adaeea4.js'); | ||
require('redent'); | ||
@@ -11,3 +11,4 @@ require('@adobe/css-tools'); | ||
require('css.escape'); | ||
require('lodash/isEqualWith'); | ||
expect.extend(matchers.extensions); |
'use strict'; | ||
var globals = require('@jest/globals'); | ||
var matchers = require('./matchers-4fe91ec3.js'); | ||
var matchers = require('./matchers-3adaeea4.js'); | ||
require('redent'); | ||
@@ -12,2 +12,3 @@ require('@adobe/css-tools'); | ||
require('css.escape'); | ||
require('lodash/isEqualWith'); | ||
@@ -14,0 +15,0 @@ /* istanbul ignore file */ |
'use strict'; | ||
var matchers = require('./matchers-4fe91ec3.js'); | ||
var matchers = require('./matchers-3adaeea4.js'); | ||
require('redent'); | ||
@@ -11,2 +11,3 @@ require('@adobe/css-tools'); | ||
require('css.escape'); | ||
require('lodash/isEqualWith'); | ||
@@ -40,4 +41,5 @@ | ||
exports.toHaveRole = matchers.toHaveRole; | ||
exports.toHaveSelection = matchers.toHaveSelection; | ||
exports.toHaveStyle = matchers.toHaveStyle; | ||
exports.toHaveTextContent = matchers.toHaveTextContent; | ||
exports.toHaveValue = matchers.toHaveValue; |
'use strict'; | ||
var vitest = require('vitest'); | ||
var matchers = require('./matchers-4fe91ec3.js'); | ||
var matchers = require('./matchers-3adaeea4.js'); | ||
require('redent'); | ||
@@ -12,2 +12,3 @@ require('@adobe/css-tools'); | ||
require('css.escape'); | ||
require('lodash/isEqualWith'); | ||
@@ -14,0 +15,0 @@ /* istanbul ignore file */ |
{ | ||
"name": "@testing-library/jest-dom", | ||
"version": "6.5.0", | ||
"version": "6.6.0", | ||
"description": "Custom jest matchers to test the state of the DOM", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -706,2 +706,60 @@ import {type ARIARole} from 'aria-query' | ||
toHaveErrorMessage(text?: string | RegExp | E): R | ||
/** | ||
* @description | ||
* This allows to assert that an element has a | ||
* [text selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection). | ||
* | ||
* This is useful to check if text or part of the text is selected within an | ||
* element. The element can be either an input of type text, a textarea, or any | ||
* other element that contains text, such as a paragraph, span, div etc. | ||
* | ||
* NOTE: the expected selection is a string, it does not allow to check for | ||
* selection range indeces. | ||
* | ||
* @example | ||
* <div> | ||
* <input type="text" value="text selected text" data-testid="text" /> | ||
* <textarea data-testid="textarea">text selected text</textarea> | ||
* <p data-testid="prev">prev</p> | ||
* <p data-testid="parent">text <span data-testid="child">selected</span> text</p> | ||
* <p data-testid="next">next</p> | ||
* </div> | ||
* | ||
* getByTestId('text').setSelectionRange(5, 13) | ||
* expect(getByTestId('text')).toHaveSelection('selected') | ||
* | ||
* getByTestId('textarea').setSelectionRange(0, 5) | ||
* expect('textarea').toHaveSelection('text ') | ||
* | ||
* const selection = document.getSelection() | ||
* const range = document.createRange() | ||
* selection.removeAllRanges() | ||
* selection.empty() | ||
* selection.addRange(range) | ||
* | ||
* // selection of child applies to the parent as well | ||
* range.selectNodeContents(getByTestId('child')) | ||
* expect(getByTestId('child')).toHaveSelection('selected') | ||
* expect(getByTestId('parent')).toHaveSelection('selected') | ||
* | ||
* // selection that applies from prev all, parent text before child, and part child. | ||
* range.setStart(getByTestId('prev'), 0) | ||
* range.setEnd(getByTestId('child').childNodes[0], 3) | ||
* expect(queryByTestId('prev')).toHaveSelection('prev') | ||
* expect(queryByTestId('child')).toHaveSelection('sel') | ||
* expect(queryByTestId('parent')).toHaveSelection('text sel') | ||
* expect(queryByTestId('next')).not.toHaveSelection() | ||
* | ||
* // selection that applies from part child, parent text after child and part next. | ||
* range.setStart(getByTestId('child').childNodes[0], 3) | ||
* range.setEnd(getByTestId('next').childNodes[0], 2) | ||
* expect(queryByTestId('child')).toHaveSelection('ected') | ||
* expect(queryByTestId('parent')).toHaveSelection('ected text') | ||
* expect(queryByTestId('prev')).not.toHaveSelection() | ||
* expect(queryByTestId('next')).toHaveSelection('ne') | ||
* | ||
* @see | ||
* [testing-library/jest-dom#tohaveselection](https://github.com/testing-library/jest-dom#tohaveselection) | ||
*/ | ||
toHaveSelection(selection?: string): R | ||
} | ||
@@ -708,0 +766,0 @@ } |
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
281280
5228
1703