expect-webdriverio 5.2.0 → 5.2.2

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/lib/index.js CHANGED
@@ -1,10 +1,16 @@
1
1
  import { expect as expectLib } from 'expect';
2
- import wdioMatchers from './matchers.js';
2
+ import * as wdioMatchers from './matchers.js';
3
3
  import { DEFAULT_OPTIONS } from './constants.js';
4
4
  import createSoftExpect from './softExpect.js';
5
5
  import { SoftAssertService } from './softAssert.js';
6
6
  export const matchers = new Map();
7
+ const filteredMatchers = {};
7
8
  const extend = expectLib.extend;
9
+ Object.keys(wdioMatchers).forEach(matcher => {
10
+ if (typeof wdioMatchers[matcher] === 'function') {
11
+ filteredMatchers[matcher] = wdioMatchers[matcher];
12
+ }
13
+ });
8
14
  expectLib.extend = (m) => {
9
15
  if (!m || typeof m !== 'object') {
10
16
  return;
@@ -12,7 +18,7 @@ expectLib.extend = (m) => {
12
18
  Object.entries(m).forEach(([name, matcher]) => matchers.set(name, matcher));
13
19
  return extend(m);
14
20
  };
15
- expectLib.extend(wdioMatchers);
21
+ expectLib.extend(filteredMatchers);
16
22
  const expectWithSoft = expectLib;
17
23
  Object.defineProperty(expectWithSoft, 'soft', {
18
24
  value: (actual) => createSoftExpect(actual)
package/lib/matchers.js CHANGED
@@ -1,62 +1,31 @@
1
- import * as toHaveClipboardText from './matchers/browser/toHaveClipboardText.js';
2
- import * as toHaveTitle from './matchers/browser/toHaveTitle.js';
3
- import * as toHaveUrl from './matchers/browser/toHaveUrl.js';
4
- import * as toBeElementsArrayOfSize from './matchers/elements/toBeElementsArrayOfSize.js';
5
- import * as toBeClickable from './matchers/element/toBeClickable.js';
6
- import * as toBeDisabled from './matchers/element/toBeDisabled.js';
7
- import * as toBeDisplayed from './matchers/element/toBeDisplayed.js';
8
- import * as toBeDisplayedInViewport from './matchers/element/toBeDisplayedInViewport.js';
9
- import * as toBeEnabled from './matchers/element/toBeEnabled.js';
10
- import * as toBeExisting from './matchers/element/toBeExisting.js';
11
- import * as toBeFocused from './matchers/element/toBeFocused.js';
12
- import * as toBeSelected from './matchers/element/toBeSelected.js';
13
- import * as toHaveAttribute from './matchers/element/toHaveAttribute.js';
14
- import * as toHaveChildren from './matchers/element/toHaveChildren.js';
15
- import * as toHaveClass from './matchers/element/toHaveClass.js';
16
- import * as toHaveHref from './matchers/element/toHaveHref.js';
17
- import * as toHaveHTML from './matchers/element/toHaveHTML.js';
18
- import * as toHaveId from './matchers/element/toHaveId.js';
19
- import * as toHaveSize from './matchers/element/toHaveSize.js';
20
- import * as toHaveElementProperty from './matchers/element/toHaveElementProperty.js';
21
- import * as toHaveText from './matchers/element/toHaveText.js';
22
- import * as toHaveValue from './matchers/element/toHaveValue.js';
23
- import * as toHaveStyle from './matchers/element/toHaveStyle.js';
24
- import * as toBeRequested from './matchers/mock/toBeRequested.js';
25
- import * as toBeRequestedTimes from './matchers/mock/toBeRequestedTimes.js';
26
- import * as toBeRequestedWith from './matchers/mock/toBeRequestedWith.js';
27
- import * as snapshotMatchers from './matchers/snapshot.js';
28
- const matchers = {
29
- ...toHaveClipboardText,
30
- ...toHaveTitle,
31
- ...toHaveUrl,
32
- ...toBeElementsArrayOfSize,
33
- ...toBeClickable,
34
- ...toBeDisabled,
35
- ...toBeDisplayed,
36
- ...toBeDisplayedInViewport,
37
- ...toBeEnabled,
38
- ...toBeExisting,
39
- ...toBeFocused,
40
- ...toBeSelected,
41
- ...toHaveAttribute,
42
- ...toHaveChildren,
43
- ...toHaveClass,
44
- ...toHaveHref,
45
- ...toHaveHTML,
46
- ...toHaveId,
47
- ...toHaveSize,
48
- ...toHaveElementProperty,
49
- ...toHaveText,
50
- ...toHaveValue,
51
- ...toHaveStyle,
52
- ...toBeRequested,
53
- ...toBeRequestedTimes,
54
- ...toBeRequestedWith,
55
- ...snapshotMatchers
56
- };
57
- Object.keys(matchers).forEach((key) => {
58
- if (key.endsWith('Fn')) {
59
- delete matchers[key];
60
- }
61
- });
62
- export default matchers;
1
+ export * from './matchers/browser/toHaveClipboardText.js';
2
+ export * from './matchers/browser/toHaveTitle.js';
3
+ export * from './matchers/browser/toHaveUrl.js';
4
+ export * from './matchers/element/toBeClickable.js';
5
+ export * from './matchers/element/toBeDisabled.js';
6
+ export * from './matchers/element/toBeDisplayed.js';
7
+ export * from './matchers/element/toBeDisplayedInViewport.js';
8
+ export * from './matchers/element/toBeEnabled.js';
9
+ export * from './matchers/element/toBeExisting.js';
10
+ export * from './matchers/element/toBeFocused.js';
11
+ export * from './matchers/element/toBeSelected.js';
12
+ export * from './matchers/element/toHaveAttribute.js';
13
+ export * from './matchers/element/toHaveChildren.js';
14
+ export * from './matchers/element/toHaveClass.js';
15
+ export * from './matchers/element/toHaveComputedLabel.js';
16
+ export * from './matchers/element/toHaveComputedRole.js';
17
+ export * from './matchers/element/toHaveElementProperty.js';
18
+ export * from './matchers/element/toHaveHeight.js';
19
+ export * from './matchers/element/toHaveHref.js';
20
+ export * from './matchers/element/toHaveHTML.js';
21
+ export * from './matchers/element/toHaveId.js';
22
+ export * from './matchers/element/toHaveSize.js';
23
+ export * from './matchers/element/toHaveStyle.js';
24
+ export * from './matchers/element/toHaveText.js';
25
+ export * from './matchers/element/toHaveValue.js';
26
+ export * from './matchers/element/toHaveWidth.js';
27
+ export * from './matchers/elements/toBeElementsArrayOfSize.js';
28
+ export * from './matchers/mock/toBeRequested.js';
29
+ export * from './matchers/mock/toBeRequestedTimes.js';
30
+ export * from './matchers/mock/toBeRequestedWith.js';
31
+ export * from './matchers/snapshot.js';
package/lib/snapshot.js CHANGED
@@ -63,17 +63,20 @@ export class SnapshotService {
63
63
  async beforeTest(test) {
64
64
  __classPrivateFieldSet(this, _SnapshotService_currentFilePath, test.file, "f");
65
65
  __classPrivateFieldSet(this, _SnapshotService_currentTestName, `${test.parent} > ${test.title}`, "f");
66
- await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").startCurrentRun(test.file, test.fullTitle, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
66
+ await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").setup(test.file, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
67
67
  }
68
68
  async beforeStep(step, scenario) {
69
69
  const file = scenario.uri;
70
70
  const testName = `${scenario.name} > ${step.text}`;
71
71
  __classPrivateFieldSet(this, _SnapshotService_currentFilePath, file, "f");
72
72
  __classPrivateFieldSet(this, _SnapshotService_currentTestName, testName, "f");
73
- await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").startCurrentRun(file, testName, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
73
+ await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").setup(file, __classPrivateFieldGet(this, _SnapshotService_options, "f"));
74
74
  }
75
75
  async after() {
76
- const result = await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").finishCurrentRun();
76
+ if (!__classPrivateFieldGet(this, _SnapshotService_currentFilePath, "f")) {
77
+ return;
78
+ }
79
+ const result = await __classPrivateFieldGet(this, _SnapshotService_snapshotClient, "f").finish(__classPrivateFieldGet(this, _SnapshotService_currentFilePath, "f"));
77
80
  if (!result) {
78
81
  return;
79
82
  }
@@ -1,4 +1,4 @@
1
- import { SoftAssertService } from './softAssert';
1
+ import { SoftAssertService } from './softAssert.js';
2
2
  export class SoftAssertionService {
3
3
  constructor(serviceOptions) {
4
4
  this.softAssertService = SoftAssertService.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expect-webdriverio",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
4
4
  "author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
5
5
  "description": "WebdriverIO Assertion Library",
6
6
  "license": "MIT",
@@ -58,29 +58,29 @@
58
58
  "prepare": "husky install"
59
59
  },
60
60
  "dependencies": {
61
- "@vitest/snapshot": "^2.0.5",
61
+ "@vitest/snapshot": "^3.2.1",
62
62
  "expect": "^29.7.0",
63
63
  "jest-matcher-utils": "^29.7.0",
64
64
  "lodash.isequal": "^4.5.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/debug": "^4.1.12",
68
- "@types/jest": "^29.5.12",
68
+ "@types/jest": "^29.5.14",
69
69
  "@types/lodash.isequal": "^4.5.8",
70
- "@types/node": "^22.9.0",
71
- "@wdio/types": "^9.9.0",
72
- "@vitest/coverage-v8": "^3.0.5",
73
- "@wdio/eslint": "^0.1.0",
74
- "c8": "^10.1.2",
75
- "eslint": "^9.15.0",
76
- "husky": "^9.1.5",
77
- "npm-run-all2": "^7.0.1",
78
- "release-it": "^19.0.1",
70
+ "@types/node": "^22.15.29",
71
+ "@vitest/coverage-v8": "^3.2.1",
72
+ "@wdio/eslint": "^0.1.1",
73
+ "@wdio/types": "^9.15.0",
74
+ "c8": "^10.1.3",
75
+ "eslint": "^9.28.0",
76
+ "husky": "^9.1.7",
77
+ "npm-run-all2": "^8.0.4",
78
+ "release-it": "^19.0.3",
79
79
  "rimraf": "^6.0.1",
80
- "shelljs": "^0.9.1",
81
- "typescript": "^5.5.4",
82
- "vitest": "^3.0.4",
83
- "webdriverio": "^9.2.11"
80
+ "shelljs": "^0.10.0",
81
+ "typescript": "^5.8.3",
82
+ "vitest": "^3.2.1",
83
+ "webdriverio": "^9.15.0"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@wdio/globals": "^9.0.0",
@@ -1,16 +1,24 @@
1
+ type ServiceInstance = import('@wdio/types').Services.ServiceInstance;
2
+ type Test = import('@wdio/types').Frameworks.Test;
3
+ type TestResult = import('@wdio/types').Frameworks.TestResult;
4
+ type PickleStep = import('@wdio/types').Frameworks.PickleStep;
5
+ type Scenario = import('@wdio/types').Frameworks.Scenario;
6
+ type SnapshotResult = import('@vitest/snapshot').SnapshotResult;
7
+ type SnapshotUpdateState = import('@vitest/snapshot').SnapshotUpdateState;
8
+
1
9
  declare namespace ExpectWebdriverIO {
2
10
  const expect: ExpectWebdriverIO.Expect
3
11
  function setOptions(options: DefaultOptions): void
4
12
  function getConfig(): any
5
13
 
6
14
  interface SnapshotServiceArgs {
7
- updateState?: import('@vitest/snapshot').SnapshotUpdateState
15
+ updateState?: SnapshotUpdateState
8
16
  resolveSnapshotPath?: (path: string, extension: string) => string
9
17
  }
10
18
 
11
19
  class SnapshotService {
12
- static initiate(options: SnapshotServiceArgs): import('@wdio/types').Services.ServiceInstance & {
13
- results: import('@vitest/snapshot').SnapshotResult[]
20
+ static initiate(options: SnapshotServiceArgs): ServiceInstance & {
21
+ results: SnapshotResult[]
14
22
  }
15
23
  }
16
24
 
@@ -35,12 +43,12 @@ declare namespace ExpectWebdriverIO {
35
43
  autoAssertOnTestEnd?: boolean;
36
44
  }
37
45
 
38
- class SoftAssertionService implements import('@wdio/types').Services.ServiceInstance {
46
+ class SoftAssertionService implements ServiceInstance {
39
47
  constructor(serviceOptions?: SoftAssertionServiceOptions, capabilities?: any, config?: any);
40
- beforeTest(test: import('@wdio/types').Frameworks.Test): void;
41
- beforeStep(step: import('@wdio/types').Frameworks.PickleStep, scenario: import('@wdio/types').Frameworks.Scenario): void;
42
- afterTest(test: import('@wdio/types').Frameworks.Test, context: any, result: import('@wdio/types').Frameworks.TestResult): void;
43
- afterStep(step: import('@wdio/types').Frameworks.PickleStep, scenario: import('@wdio/types').Frameworks.Scenario, result: { passed: boolean, error?: Error }): void;
48
+ beforeTest(test: Test): void;
49
+ beforeStep(step: PickleStep, scenario: Scenario): void;
50
+ afterTest(test: Test, context: any, result: TestResult): void;
51
+ afterStep(step: PickleStep, scenario: Scenario, result: { passed: boolean, error?: Error }): void;
44
52
  }
45
53
 
46
54
  interface AssertionResult {