expect-webdriverio 4.5.2 → 4.6.1

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 (44) hide show
  1. package/lib/constants.js +2 -0
  2. package/lib/matchers/browser/toHaveClipboardText.js +38 -0
  3. package/lib/matchers/browser/toHaveTitle.js +23 -4
  4. package/lib/matchers/browser/toHaveUrl.js +23 -4
  5. package/lib/matchers/element/toBeClickable.js +13 -2
  6. package/lib/matchers/element/toBeDisabled.js +13 -2
  7. package/lib/matchers/element/toBeDisplayed.js +13 -2
  8. package/lib/matchers/element/toBeDisplayedInViewport.js +13 -2
  9. package/lib/matchers/element/toBeEnabled.js +13 -2
  10. package/lib/matchers/element/toBeExisting.js +13 -2
  11. package/lib/matchers/element/toBeFocused.js +13 -2
  12. package/lib/matchers/element/toBeSelected.js +25 -4
  13. package/lib/matchers/element/toHaveAttribute.js +26 -9
  14. package/lib/matchers/element/toHaveChildren.js +18 -5
  15. package/lib/matchers/element/toHaveClass.js +29 -6
  16. package/lib/matchers/element/toHaveComputedLabel.js +24 -5
  17. package/lib/matchers/element/toHaveComputedRole.js +24 -5
  18. package/lib/matchers/element/toHaveElementProperty.js +17 -4
  19. package/lib/matchers/element/toHaveHTML.js +23 -4
  20. package/lib/matchers/element/toHaveHeight.js +18 -5
  21. package/lib/matchers/element/toHaveHref.js +23 -3
  22. package/lib/matchers/element/toHaveId.js +16 -3
  23. package/lib/matchers/element/toHaveSize.js +18 -5
  24. package/lib/matchers/element/toHaveStyle.js +17 -4
  25. package/lib/matchers/element/toHaveText.js +23 -4
  26. package/lib/matchers/element/toHaveValue.js +8 -1
  27. package/lib/matchers/element/toHaveWidth.js +18 -5
  28. package/lib/matchers/elements/toBeElementsArrayOfSize.js +19 -6
  29. package/lib/matchers/mock/toBeRequested.js +3 -2
  30. package/lib/matchers/mock/toBeRequestedTimes.js +19 -6
  31. package/lib/matchers/mock/toBeRequestedWith.js +24 -11
  32. package/lib/matchers.js +4 -14
  33. package/package.json +2 -1
  34. package/types/expect-webdriverio.d.ts +74 -5
  35. package/lib/matchers/browser/toHaveTitleContaining.js +0 -7
  36. package/lib/matchers/browser/toHaveUrlContaining.js +0 -7
  37. package/lib/matchers/element/toHaveAttributeContaining.js +0 -8
  38. package/lib/matchers/element/toHaveClassContaining.js +0 -10
  39. package/lib/matchers/element/toHaveComputedLabelContaining.js +0 -7
  40. package/lib/matchers/element/toHaveComputedRoleContaining.js +0 -7
  41. package/lib/matchers/element/toHaveHTMLContaining.js +0 -7
  42. package/lib/matchers/element/toHaveHrefContaining.js +0 -8
  43. package/lib/matchers/element/toHaveTextContaining.js +0 -7
  44. package/lib/matchers/element/toHaveValueContaining.js +0 -7
@@ -1,4 +1,5 @@
1
1
  import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, html, options) {
3
4
  const actualHTML = await el.getHTML(options.includeSelectorTag);
4
5
  if (Array.isArray(html)) {
@@ -6,21 +7,39 @@ async function condition(el, html, options) {
6
7
  }
7
8
  return compareText(actualHTML, html, options);
8
9
  }
9
- export async function toHaveHTML(received, html, options = {}) {
10
+ export async function toHaveHTML(received, expectedValue, options = DEFAULT_OPTIONS) {
10
11
  const isNot = this.isNot;
11
12
  const { expectation = 'HTML', verb = 'have' } = this;
13
+ await options.beforeAssertion?.({
14
+ matcherName: 'toHaveHTML',
15
+ expectedValue,
16
+ options,
17
+ });
12
18
  let el = await received;
13
19
  let actualHTML;
14
20
  const pass = await waitUntil(async () => {
15
- const result = await executeCommand.call(this, el, condition, options, [html, options]);
21
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
16
22
  el = result.el;
17
23
  actualHTML = result.values;
18
24
  return result.success;
19
25
  }, isNot, options);
20
26
  updateElementsArray(pass, received, el);
21
- const message = enhanceError(el, wrapExpectedWithArray(el, actualHTML, html), actualHTML, this, verb, expectation, '', options);
22
- return {
27
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualHTML, expectedValue), actualHTML, this, verb, expectation, '', options);
28
+ const result = {
23
29
  pass,
24
30
  message: () => message
25
31
  };
32
+ await options.afterAssertion?.({
33
+ matcherName: 'toHaveHTML',
34
+ expectedValue,
35
+ options,
36
+ result
37
+ });
38
+ return result;
39
+ }
40
+ export function toHaveHTMLContaining(el, html, options = DEFAULT_OPTIONS) {
41
+ return toHaveHTML.call(this, el, html, {
42
+ ...options,
43
+ containing: true
44
+ });
26
45
  }
@@ -1,4 +1,5 @@
1
1
  import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, height) {
3
4
  const actualHeight = await el.getSize('height');
4
5
  return {
@@ -6,21 +7,33 @@ async function condition(el, height) {
6
7
  result: actualHeight === height,
7
8
  };
8
9
  }
9
- export async function toHaveHeight(received, height, options = {}) {
10
+ export async function toHaveHeight(received, expectedValue, options = DEFAULT_OPTIONS) {
10
11
  const isNot = this.isNot;
11
12
  const { expectation = 'height', verb = 'have' } = this;
13
+ await options.beforeAssertion?.({
14
+ matcherName: 'toHaveHeight',
15
+ expectedValue,
16
+ options,
17
+ });
12
18
  let el = await received;
13
19
  let actualHeight;
14
20
  const pass = await waitUntil(async () => {
15
- const result = await executeCommand.call(this, el, condition, options, [height, options]);
21
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
16
22
  el = result.el;
17
23
  actualHeight = result.values;
18
24
  return result.success;
19
25
  }, isNot, options);
20
26
  updateElementsArray(pass, received, el);
21
- const message = enhanceError(el, wrapExpectedWithArray(el, actualHeight, height), actualHeight, this, verb, expectation, '', options);
22
- return {
27
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualHeight, expectedValue), actualHeight, this, verb, expectation, '', options);
28
+ const result = {
23
29
  pass,
24
- message: () => message,
30
+ message: () => message
25
31
  };
32
+ await options.afterAssertion?.({
33
+ matcherName: 'toHaveHeight',
34
+ expectedValue,
35
+ options,
36
+ result
37
+ });
38
+ return result;
26
39
  }
@@ -1,5 +1,25 @@
1
- import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
2
- export function toHaveHref(el, href, options = {}) {
3
- return toHaveAttributeAndValueFn.call(this, el, 'href', href, options);
1
+ import { toHaveAttributeAndValue } from './toHaveAttribute.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
3
+ export async function toHaveHref(el, expectedValue, options = DEFAULT_OPTIONS) {
4
+ await options.beforeAssertion?.({
5
+ matcherName: 'toHaveHref',
6
+ expectedValue,
7
+ options,
8
+ });
9
+ const result = await toHaveAttributeAndValue.call(this, el, 'href', expectedValue, options);
10
+ await options.afterAssertion?.({
11
+ matcherName: 'toHaveHref',
12
+ expectedValue,
13
+ options,
14
+ result
15
+ });
16
+ return result;
4
17
  }
5
18
  export const toHaveLink = toHaveHref;
19
+ export function toHaveHrefContaining(el, href, options = DEFAULT_OPTIONS) {
20
+ return toHaveHref.call(this, el, href, {
21
+ ...options,
22
+ containing: true
23
+ });
24
+ }
25
+ export const toHaveLinkContaining = toHaveHrefContaining;
@@ -1,4 +1,17 @@
1
- import { toHaveAttributeAndValueFn } from './toHaveAttribute.js';
2
- export function toHaveId(el, id, options = {}) {
3
- return toHaveAttributeAndValueFn.call(this, el, 'id', id, options);
1
+ import { toHaveAttributeAndValue } from './toHaveAttribute.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
3
+ export async function toHaveId(el, expectedValue, options = DEFAULT_OPTIONS) {
4
+ await options.beforeAssertion?.({
5
+ matcherName: 'toHaveId',
6
+ expectedValue,
7
+ options,
8
+ });
9
+ const result = await toHaveAttributeAndValue.call(this, el, 'id', expectedValue, options);
10
+ await options.afterAssertion?.({
11
+ matcherName: 'toHaveId',
12
+ expectedValue,
13
+ options,
14
+ result
15
+ });
16
+ return result;
4
17
  }
@@ -1,23 +1,36 @@
1
1
  import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, compareObject, } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, size) {
3
4
  const actualSize = await el.getSize();
4
5
  return compareObject(actualSize, size);
5
6
  }
6
- export async function toHaveSize(received, size, options = {}) {
7
+ export async function toHaveSize(received, expectedValue, options = DEFAULT_OPTIONS) {
7
8
  const isNot = this.isNot;
8
9
  const { expectation = 'size', verb = 'have' } = this;
10
+ await options.beforeAssertion?.({
11
+ matcherName: 'toHaveSize',
12
+ expectedValue,
13
+ options,
14
+ });
9
15
  let el = await received;
10
16
  let actualSize;
11
17
  const pass = await waitUntil(async () => {
12
- const result = await executeCommand.call(this, el, condition, options, [size, options]);
18
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
13
19
  el = result.el;
14
20
  actualSize = result.values;
15
21
  return result.success;
16
22
  }, isNot, options);
17
23
  updateElementsArray(pass, received, el);
18
- const message = enhanceError(el, wrapExpectedWithArray(el, actualSize, size), actualSize, this, verb, expectation, '', options);
19
- return {
24
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualSize, expectedValue), actualSize, this, verb, expectation, '', options);
25
+ const result = {
20
26
  pass,
21
- message: () => message,
27
+ message: () => message
22
28
  };
29
+ await options.afterAssertion?.({
30
+ matcherName: 'toHaveSize',
31
+ expectedValue,
32
+ options,
33
+ result
34
+ });
35
+ return result;
23
36
  }
@@ -1,22 +1,35 @@
1
1
  import { waitUntil, enhanceError, compareStyle, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, style, options) {
3
4
  return compareStyle(el, style, options);
4
5
  }
5
- export async function toHaveStyle(received, style, options = {}) {
6
+ export async function toHaveStyle(received, expectedValue, options = DEFAULT_OPTIONS) {
6
7
  const isNot = this.isNot;
7
8
  const { expectation = 'style', verb = 'have' } = this;
9
+ await options.beforeAssertion?.({
10
+ matcherName: 'toHaveStyle',
11
+ expectedValue,
12
+ options,
13
+ });
8
14
  let el = await received;
9
15
  let actualStyle;
10
16
  const pass = await waitUntil(async () => {
11
- const result = await executeCommand.call(this, el, condition, options, [style, options]);
17
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
12
18
  el = result.el;
13
19
  actualStyle = result.values;
14
20
  return result.success;
15
21
  }, isNot, options);
16
22
  updateElementsArray(pass, received, el);
17
- const message = enhanceError(el, wrapExpectedWithArray(el, actualStyle, style), actualStyle, this, verb, expectation, '', options);
18
- return {
23
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualStyle, expectedValue), actualStyle, this, verb, expectation, '', options);
24
+ const result = {
19
25
  pass,
20
26
  message: () => message
21
27
  };
28
+ await options.afterAssertion?.({
29
+ matcherName: 'toHaveStyle',
30
+ expectedValue,
31
+ options,
32
+ result
33
+ });
34
+ return result;
22
35
  }
@@ -1,4 +1,5 @@
1
1
  import { waitUntil, enhanceError, compareText, compareTextWithArray, executeCommand, wrapExpectedWithArray, updateElementsArray } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, text, options) {
3
4
  const actualText = await el.getText();
4
5
  if (Array.isArray(text)) {
@@ -6,21 +7,39 @@ async function condition(el, text, options) {
6
7
  }
7
8
  return compareText(actualText, text, options);
8
9
  }
9
- export async function toHaveText(received, text, options = {}) {
10
+ export async function toHaveText(received, expectedValue, options = DEFAULT_OPTIONS) {
10
11
  const isNot = this.isNot;
11
12
  const { expectation = 'text', verb = 'have' } = this;
13
+ await options.beforeAssertion?.({
14
+ matcherName: 'toHaveText',
15
+ expectedValue,
16
+ options,
17
+ });
12
18
  let el = await received;
13
19
  let actualText;
14
20
  const pass = await waitUntil(async () => {
15
- const result = await executeCommand.call(this, el, condition, options, [text, options]);
21
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
16
22
  el = result.el;
17
23
  actualText = result.values;
18
24
  return result.success;
19
25
  }, isNot, options);
20
26
  updateElementsArray(pass, received, el);
21
- const message = enhanceError(el, wrapExpectedWithArray(el, actualText, text), actualText, this, verb, expectation, '', options);
22
- return {
27
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualText, expectedValue), actualText, this, verb, expectation, '', options);
28
+ const result = {
23
29
  pass,
24
30
  message: () => message
25
31
  };
32
+ await options.afterAssertion?.({
33
+ matcherName: 'toHaveText',
34
+ expectedValue,
35
+ options,
36
+ result
37
+ });
38
+ return result;
39
+ }
40
+ export function toHaveTextContaining(el, text, options = DEFAULT_OPTIONS) {
41
+ return toHaveText.call(this, el, text, {
42
+ ...options,
43
+ containing: true
44
+ });
26
45
  }
@@ -1,4 +1,11 @@
1
1
  import { toHaveElementProperty } from './toHaveElementProperty.js';
2
- export function toHaveValue(el, value, options = {}) {
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
3
+ export function toHaveValue(el, value, options = DEFAULT_OPTIONS) {
3
4
  return toHaveElementProperty.call(this, el, 'value', value, options);
4
5
  }
6
+ export function toHaveValueContaining(el, value, options = DEFAULT_OPTIONS) {
7
+ return toHaveValue.call(this, el, value, {
8
+ ...options,
9
+ containing: true
10
+ });
11
+ }
@@ -1,4 +1,5 @@
1
1
  import { waitUntil, enhanceError, executeCommand, wrapExpectedWithArray, updateElementsArray, } from '../../utils.js';
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
2
3
  async function condition(el, width) {
3
4
  const actualWidth = await el.getSize('width');
4
5
  return {
@@ -6,21 +7,33 @@ async function condition(el, width) {
6
7
  result: actualWidth === width,
7
8
  };
8
9
  }
9
- export async function toHaveWidth(received, width, options = {}) {
10
+ export async function toHaveWidth(received, expectedValue, options = DEFAULT_OPTIONS) {
10
11
  const isNot = this.isNot;
11
12
  const { expectation = 'width', verb = 'have' } = this;
13
+ await options.beforeAssertion?.({
14
+ matcherName: 'toHaveWidth',
15
+ expectedValue,
16
+ options,
17
+ });
12
18
  let el = await received;
13
19
  let actualWidth;
14
20
  const pass = await waitUntil(async () => {
15
- const result = await executeCommand.call(this, el, condition, options, [width, options]);
21
+ const result = await executeCommand.call(this, el, condition, options, [expectedValue, options]);
16
22
  el = result.el;
17
23
  actualWidth = result.values;
18
24
  return result.success;
19
25
  }, isNot, options);
20
26
  updateElementsArray(pass, received, el);
21
- const message = enhanceError(el, wrapExpectedWithArray(el, actualWidth, width), actualWidth, this, verb, expectation, '', options);
22
- return {
27
+ const message = enhanceError(el, wrapExpectedWithArray(el, actualWidth, expectedValue), actualWidth, this, verb, expectation, '', options);
28
+ const result = {
23
29
  pass,
24
- message: () => message,
30
+ message: () => message
25
31
  };
32
+ await options.afterAssertion?.({
33
+ matcherName: 'toHaveWidth',
34
+ expectedValue,
35
+ options,
36
+ result
37
+ });
38
+ return result;
26
39
  }
@@ -1,17 +1,23 @@
1
1
  import { waitUntil, enhanceError, compareNumbers, numberError, updateElementsArray } from '../../utils.js';
2
2
  import { refetchElements } from '../../util/refetchElements.js';
3
- export async function toBeElementsArrayOfSize(received, expected, options = {}) {
3
+ import { DEFAULT_OPTIONS } from '../../constants.js';
4
+ export async function toBeElementsArrayOfSize(received, expectedValue, options = DEFAULT_OPTIONS) {
4
5
  const isNot = this.isNot;
5
6
  const { expectation = 'elements array of size', verb = 'be' } = this;
7
+ await options.beforeAssertion?.({
8
+ matcherName: 'toBeElementsArrayOfSize',
9
+ expectedValue,
10
+ options,
11
+ });
6
12
  let numberOptions;
7
- if (typeof expected === 'number') {
8
- numberOptions = { eq: expected };
13
+ if (typeof expectedValue === 'number') {
14
+ numberOptions = { eq: expectedValue };
9
15
  }
10
- else if (!expected || (typeof expected.eq !== 'number' && typeof expected.gte !== 'number' && typeof expected.lte !== 'number')) {
16
+ else if (!expectedValue || (typeof expectedValue.eq !== 'number' && typeof expectedValue.gte !== 'number' && typeof expectedValue.lte !== 'number')) {
11
17
  throw new Error('Invalid params passed to toBeElementsArrayOfSize.');
12
18
  }
13
19
  else {
14
- numberOptions = expected;
20
+ numberOptions = expectedValue;
15
21
  }
16
22
  let elements = await received;
17
23
  const arrLength = elements.length;
@@ -22,8 +28,15 @@ export async function toBeElementsArrayOfSize(received, expected, options = {})
22
28
  updateElementsArray(pass, received, elements, true);
23
29
  const error = numberError(numberOptions);
24
30
  const message = enhanceError(elements, error, arrLength, this, verb, expectation, '', numberOptions);
25
- return {
31
+ const result = {
26
32
  pass,
27
33
  message: () => message
28
34
  };
35
+ await options.afterAssertion?.({
36
+ matcherName: 'toBeElementsArrayOfSize',
37
+ expectedValue,
38
+ options,
39
+ result
40
+ });
41
+ return result;
29
42
  }
@@ -1,4 +1,5 @@
1
1
  import { toBeRequestedTimes } from './toBeRequestedTimes.js';
2
- export function toBeRequested(received, options = {}) {
3
- return toBeRequestedTimes.call({ ...(this || {}), expectation: 'called' }, received, { ...options, gte: 1 });
2
+ import { DEFAULT_OPTIONS } from '../../constants.js';
3
+ export function toBeRequested(received, options = DEFAULT_OPTIONS) {
4
+ return toBeRequestedTimes.call({ ...(this || {}), expectation: 'called' }, received, { gte: 1 }, options);
4
5
  }
@@ -1,11 +1,17 @@
1
1
  import { waitUntil, enhanceError, compareNumbers } from '../../utils.js';
2
2
  import { numberError } from '../../util/formatMessage.js';
3
- export async function toBeRequestedTimes(received, expected = {}, options = {}) {
3
+ import { DEFAULT_OPTIONS } from '../../constants.js';
4
+ export async function toBeRequestedTimes(received, expectedValue = {}, options = DEFAULT_OPTIONS) {
4
5
  const isNot = this.isNot || false;
5
- const { expectation = `called${typeof expected === 'number' ? ' ' + expected : ''} time${expected !== 1 ? 's' : ''}`, verb = 'be' } = this;
6
- const numberOptions = typeof expected === 'number'
7
- ? { eq: expected }
8
- : expected || {};
6
+ const { expectation = `called${typeof expectedValue === 'number' ? ' ' + expectedValue : ''} time${expectedValue !== 1 ? 's' : ''}`, verb = 'be' } = this;
7
+ await options.beforeAssertion?.({
8
+ matcherName: 'toBeRequestedTimes',
9
+ expectedValue,
10
+ options,
11
+ });
12
+ const numberOptions = typeof expectedValue === 'number'
13
+ ? { eq: expectedValue }
14
+ : expectedValue || {};
9
15
  let actual;
10
16
  const pass = await waitUntil(async () => {
11
17
  actual = received.calls.length;
@@ -13,8 +19,15 @@ export async function toBeRequestedTimes(received, expected = {}, options = {})
13
19
  }, isNot, { ...numberOptions, ...options });
14
20
  const error = numberError(numberOptions);
15
21
  const message = enhanceError('mock', error, actual, this, verb, expectation, '', numberOptions);
16
- return {
22
+ const result = {
17
23
  pass,
18
24
  message: () => message
19
25
  };
26
+ await options.afterAssertion?.({
27
+ matcherName: 'toBeRequestedTimes',
28
+ expectedValue,
29
+ options,
30
+ result
31
+ });
32
+ return result;
20
33
  }
@@ -1,31 +1,44 @@
1
1
  import { waitUntil, enhanceError } from '../../utils.js';
2
2
  import { equals } from '../../jasmineUtils.js';
3
+ import { DEFAULT_OPTIONS } from '../../constants.js';
3
4
  const STR_LIMIT = 80;
4
5
  const KEY_LIMIT = 12;
5
- export async function toBeRequestedWith(received, requestedWith = {}, options = {}) {
6
+ export async function toBeRequestedWith(received, expectedValue = {}, options = DEFAULT_OPTIONS) {
6
7
  const isNot = this.isNot || false;
7
8
  const { expectation = 'called with', verb = 'be' } = this;
9
+ await options.beforeAssertion?.({
10
+ matcherName: 'toBeRequestedWith',
11
+ expectedValue,
12
+ options,
13
+ });
8
14
  let actual;
9
15
  const pass = await waitUntil(async () => {
10
16
  for (const call of received.calls) {
11
17
  actual = call;
12
- if (methodMatcher(call.method, requestedWith.method) &&
13
- statusCodeMatcher(call.statusCode, requestedWith.statusCode) &&
14
- urlMatcher(call.url, requestedWith.url) &&
15
- headersMatcher(call.headers, requestedWith.requestHeaders) &&
16
- headersMatcher(call.responseHeaders, requestedWith.responseHeaders) &&
17
- bodyMatcher(call.postData, requestedWith.postData) &&
18
- bodyMatcher(call.body, requestedWith.response)) {
18
+ if (methodMatcher(call.method, expectedValue.method) &&
19
+ statusCodeMatcher(call.statusCode, expectedValue.statusCode) &&
20
+ urlMatcher(call.url, expectedValue.url) &&
21
+ headersMatcher(call.headers, expectedValue.requestHeaders) &&
22
+ headersMatcher(call.responseHeaders, expectedValue.responseHeaders) &&
23
+ bodyMatcher(call.postData, expectedValue.postData) &&
24
+ bodyMatcher(call.body, expectedValue.response)) {
19
25
  return true;
20
26
  }
21
27
  }
22
28
  return false;
23
29
  }, isNot, { ...options, wait: isNot ? 0 : options.wait });
24
- const message = enhanceError('mock', minifyRequestedWith(requestedWith), minifyRequestMock(actual, requestedWith) || 'was not called', this, verb, expectation, '', options);
25
- return {
30
+ const message = enhanceError('mock', minifyRequestedWith(expectedValue), minifyRequestMock(actual, expectedValue) || 'was not called', this, verb, expectation, '', options);
31
+ const result = {
26
32
  pass,
27
- message: () => message,
33
+ message: () => message
28
34
  };
35
+ await options.afterAssertion?.({
36
+ matcherName: 'toBeRequestedWith',
37
+ expectedValue,
38
+ options,
39
+ result
40
+ });
41
+ return result;
29
42
  }
30
43
  const methodMatcher = (method, expected) => {
31
44
  if (typeof expected === 'undefined') {
package/lib/matchers.js CHANGED
@@ -1,7 +1,6 @@
1
+ import * as toHaveClipboardText from './matchers/browser/toHaveClipboardText.js';
1
2
  import * as toHaveTitle from './matchers/browser/toHaveTitle.js';
2
- import * as toHaveTitleContaining from './matchers/browser/toHaveTitleContaining.js';
3
3
  import * as toHaveUrl from './matchers/browser/toHaveUrl.js';
4
- import * as toHaveUrlContaining from './matchers/browser/toHaveUrlContaining.js';
5
4
  import * as toBeElementsArrayOfSize from './matchers/elements/toBeElementsArrayOfSize.js';
6
5
  import * as toBeClickable from './matchers/element/toBeClickable.js';
7
6
  import * as toBeDisabled from './matchers/element/toBeDisabled.js';
@@ -12,27 +11,22 @@ import * as toBeExisting from './matchers/element/toBeExisting.js';
12
11
  import * as toBeFocused from './matchers/element/toBeFocused.js';
13
12
  import * as toBeSelected from './matchers/element/toBeSelected.js';
14
13
  import * as toHaveAttribute from './matchers/element/toHaveAttribute.js';
15
- import * as toHaveAttributeContaining from './matchers/element/toHaveAttributeContaining.js';
16
14
  import * as toHaveChildren from './matchers/element/toHaveChildren.js';
17
15
  import * as toHaveClass from './matchers/element/toHaveClass.js';
18
- import * as toHaveClassContaining from './matchers/element/toHaveClassContaining.js';
19
16
  import * as toHaveHref from './matchers/element/toHaveHref.js';
20
- import * as toHaveHrefContaining from './matchers/element/toHaveHrefContaining.js';
21
17
  import * as toHaveId from './matchers/element/toHaveId.js';
18
+ import * as toHaveSize from './matchers/element/toHaveSize.js';
22
19
  import * as toHaveElementProperty from './matchers/element/toHaveElementProperty.js';
23
20
  import * as toHaveText from './matchers/element/toHaveText.js';
24
- import * as toHaveTextContaining from './matchers/element/toHaveTextContaining.js';
25
21
  import * as toHaveValue from './matchers/element/toHaveValue.js';
26
- import * as toHaveValueContaining from './matchers/element/toHaveValueContaining.js';
27
22
  import * as toHaveStyle from './matchers/element/toHaveStyle.js';
28
23
  import * as toBeRequested from './matchers/mock/toBeRequested.js';
29
24
  import * as toBeRequestedTimes from './matchers/mock/toBeRequestedTimes.js';
30
25
  import * as toBeRequestedWith from './matchers/mock/toBeRequestedWith.js';
31
26
  const matchers = {
27
+ ...toHaveClipboardText,
32
28
  ...toHaveTitle,
33
- ...toHaveTitleContaining,
34
29
  ...toHaveUrl,
35
- ...toHaveUrlContaining,
36
30
  ...toBeElementsArrayOfSize,
37
31
  ...toBeClickable,
38
32
  ...toBeDisabled,
@@ -43,18 +37,14 @@ const matchers = {
43
37
  ...toBeFocused,
44
38
  ...toBeSelected,
45
39
  ...toHaveAttribute,
46
- ...toHaveAttributeContaining,
47
40
  ...toHaveChildren,
48
41
  ...toHaveClass,
49
- ...toHaveClassContaining,
50
42
  ...toHaveHref,
51
- ...toHaveHrefContaining,
52
43
  ...toHaveId,
44
+ ...toHaveSize,
53
45
  ...toHaveElementProperty,
54
46
  ...toHaveText,
55
- ...toHaveTextContaining,
56
47
  ...toHaveValue,
57
- ...toHaveValueContaining,
58
48
  ...toHaveStyle,
59
49
  ...toBeRequested,
60
50
  ...toBeRequestedTimes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "4.5.2",
3
+ "version": "4.6.1",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -81,6 +81,7 @@
81
81
  },
82
82
  "optionalDependencies": {
83
83
  "@wdio/globals": "^8.23.1",
84
+ "@wdio/logger": "^8.16.17",
84
85
  "webdriverio": "^8.23.1"
85
86
  },
86
87
  "dependencies": {